Want conditional statements to fire only after {submit}
Posted: Sat Sep 12, 2009 11:19 am
How can I set it up so the conditional statements to fire only after {submit} button is clicked? Right now the condition checking whether the field is empty or not is firing upon landing prior to submit button being clicked.
Code: Select all
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?
/* unsetting variables for email and the email error messages */
unset($email);
unset($emailerror);
$email = $_POST['email'];
if (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $email) && $email != ""){
$emailerror = "\t<font color=red> Invalid email</font>\n";
}
if ($email == ""){
$emailerror = "\t<font color=red> No email address entered</font>\n";
}
?>
<form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post">
<input type="text" name="email" maxlength="30">
<input type="submit" name="subjoin" value="Submit!">
<? echo "\t<br>\n";
echo $emailerror; ?>
</form>
</body>
</html>