Hi All,
I've created a form, whereby if fields are not filled in then the form should not be processed:
However, it seems to ignore my rules I created and just proceed to the next page?PHP Code:<?php
// ** If Submit is hit do your stuff **
if (isset($_POST['Submit'])) {
$your_name = $_POST['your_name'];
$your_email = $_POST['your_email'];
// ** Check for Required Fields with IF statements **
if (empty($your_name)){
$error = "** You forgot to enter your name! **";
} else if (empty($your_email)){
$error = "** Error: You forgot to enter your email! **";
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Submit_test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="process_submission.php" method="POST" enctype="multipart/form-data">
<?php echo $error?>
<table width="475" border="0" cellpadding="0" cellspacing="5" bgcolor="FFFFFF">
<tr>
<td colspan="2" class="formtext"><strong>Personal Details</strong></td>
</tr>
<input type=hidden name=subject value="News Submission Form">
<tr>
<td width="239" align="left" valign="middle" class="formtext">Name:</td>
<td align="left" valign="middle"> <INPUT TYPE="text" NAME="your_name"></td>
</tr>
<tr>
<td class="formtext">Address:</td>
<td><INPUT TYPE="text" NAME="your_address"> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"> </td>
</tr>
</table>
</form>
</body>
</html>
Any help please?
Thanks
Chris


Reply With Quote
Bookmarks