Problem with posting back to the same page

If the visitor has not submitted his name, then a form for him to do so is displayed. However if the visitor has submitted his name then the page is supposed to redisplay with a message including the visitor’s name.

For some reason the visitor’s name is not submitting thus each time the ‘submit’ button is clicked the form displays everytime.

Can anyone see what is going wrong? (Code is below)

Hello Visitor

Hello Visitor

<?php if (empty($visitorName)) { print <<<HERE Please enter your name:
HERE; } else { print "

Hi there, $visitorName!

"; } //end ?>

You need to turn on register_globals = On in your php.ini for your code to work. Or better yet, replace any instance of $visitorName with $_POST[“visitorName”] in your code.

Sponsor our Newsletter | Privacy Policy | Terms of Service