Hi,
I am trying to create a user registration page and appear to be having a problem using IF { ELSE } .
Here is a piece of code:
if ( !$submit)
{
echo "<form action=\"tform2.php\" method=\"get\">";
echo "<center>";
echo "<table>";
echo "<tr><td colspan = 2 bgcolor=\"#000000\"><font color=\"#aaddaa\"><center>Online Registration</center></font></td></td>" ;
echo "<tr><td>first name";
echo "<td><input type=\"text\" name=\"namef\" size=40></tr></td>";
echo "<tr><td>last name</td>";
echo "<td><input type=\"text\" name= \"namel\" size=40></tr></td>";
echo "<tr><td> </td>";
echo "<td><center><input type=\"submit\" name=\"submit\" value=\"submit\"></center></tr></td>";
echo "<tr><td colspan=2><center>Section</center></td></td>" ;
echo "</table></center></form>";
if ( $submit && ($namef || $namel ))
{
echo "<br><br><b><font size=+2><font color=\"blue\">";
echo "<center>Your data has been successfully entered.";
echo "</b></center></font></font>";
}
if ( $submit && (!$namef || !$namel ))
{
$errorList = array();
$count = 0;
if (!$namef) { $errorList[$count] = "Missing first name"; $count++; }
if (!$namel) { $errorList[$count] = "Missing last name"; $count++; }
// if (sizeof($errorList) == 0)
echo "<br><br><font size=+1><center>";
echo "You <font color=\"#FF0000\"><b>must</b></font> ";
echo "Please enter required data!<br><br>";
for ($x=0; $x < sizeof($errorList); $x++)
{ echo "$errorList[$x] <br>"; }
echo "<br><a href=\"tform2.php\">here</a> to start over";
echo "</font></center><br><br>";
}
}
?>
Can someone tell me why it doesn't report errors after clicking submit with empty fields?
Thanks,
Peter