I tried to run the following code on my localhost, but the server says that 'seemform' is an undefiend variable. Does someone know what is wrong with this?
<html>
<head>
<title>Listing 10-4</title>
</head>
<body>
<?
// all double quotations in $form must be escaped,
// otherwise a parse error will occur
$form = "
<form action=\"listing10-4.php\" method=\"post\" name=\"form1\">
<input type=\"hidden\" name=\"seenform\" value=\"y\">
<b>Give us some information!</b><br>
Your Name:<br>
<input type=\"text\" name=\"name\" size=\"20\" maxlength=\"20\" value=\"\"><br>
Your Email:<br>
<input type=\"text\" name=\"email\" size=\"20\" maxlength=\"40\" value=\"\"><br>
<input type=\"submit\" value=\"subscribe!\">
</form>";
// If we haven't already seen the form ($seenform passed by hidden
// form value), show the form.
if ($seenform != "y"):
print "$form";
else :
print "Hi, $name!. Your email address is $email";
endif;
?>
</body>
</html>
Someone told me to use $_POST['seemform'], instead of saying undefined variable, the server says 'seemform' is undefined index. Could someone tell me what should be correct code in the above code?
Thanks