I'm trying to adapt a script from Larry Ullman's book, PHP Advanced. I can't get the error messages to display and I can't get it to print out the "you did it," which should signal that the scrit eval'd without errors. Here's the script, which I've really had a hard time making work:
<?php
$this_script = $_SERVER['PHP_SELF'];
$form_block = "<div align=\"center\"><h1>Register</h1></div>
<form name=\"FormName\" action=\"$this_script\" method=\"post\">
<div align=\"left\">
Please enter your first name:<input name=\"f_name\" type=\"text\" value=\"$HTTP_POST_VARS[f_name]\"><br>
<br>
Please enter your last name:<input name=\"l_name\" type=\"text\" value=\"$HTTP_POST_VARS[l_name]\">
<input type=\"Submit\" value=\"Submit\">
<br>
<p>After completing this form, you will be e-mailed a link which you must click
on to complete the registration process.</p>
</div>
</form>";
if (isset($_POST['Submit'])) {
//Check f_name
if (eregi ("^[[:alnum:]]+$",$HTTP_POST_VARS['f_name'])) {
$a = TRUE;
} else {
$a = FALSE;
$message[]= "Please enter your first name.";
}
//Check l_name
if (eregi("^[[:alnum:]]+$",$HTTP_POST_VARS['l_name'])) {
$b = TRUE;
}
else {
$b = FALSE;
$message[]= "Please enter your first name.";
}
if ($a AND $b){
echo "You did it!";
exit;
}
}
else{
?>
<html>
<head>
<title></title>
</head>
<body>
<?php
if ($message){
echo "<div align=\"left\"><font color=red><b>The following problems occurred:</b>
<br />\n";
foreach ($message as $key => $value) {
echo "$value <br />\n";}
echo "<p></p></font></b></div>";
}
}
echo $message;
echo $form_block;
?>
</body>
</html>
Any ideas?