I have been working on this code for awhile know. I have my validation running but not as well I like it. When I go and fill out the form i purposely miss some input and text box to test my validation and press send on the form which work and tell me what I am missing but in the mean time the PHP script send the email before I fix the missing field can anyone tell me why? and how I can fix this problem.
[php]
<?php If($_POST["submit"]){ If (isset ($_POST['name'] , $_POST['siteArea'] , $_POST['problem'] , $_POST['email'] , $_POST['comment'])) { if (empty($_POST['name'])){ //Validate user Name $errors[] = "Please enter a Name"; } else{ $name = htmlentities($_POST['name']); } if (empty($_POST['siteArea'])){ //Validate user Name $errors[] = "You have not entered where the stie problem is"; } else{ $siteArea = htmlentities($_POST['siteArea']); } if (empty($_POST['problem'])){ //Validate user Name $errors[] = "You have not entered what the problem is"; } else{ $problem = htmlentities($_POST['problem']); } // Validate sending email If(empty($_POST['email'])){ $errors[] = "please enter a validate eMail Address."; }else if(strlen($_POST['email']) > 350){ $errors[] = "Your eMail maybe to long. Please review and correct."; }else if (filter_var($_POST['email'] , FILTER_VALIDATE_EMAIL) === false){ $errors[] = "Please provide your right email address."; }else { $email = "<" .htmlentities($_POST['email']) . ">"; } //// Validate the input message text If(empty($POST['comment'])){ $errors[] = "Please enter in a message."; }else{ $comment = htmlentities($_POST['comment']); } } $myemail = 'root@localhost'; $to = $myemail; $subject = "Your Lady of interest name: $firstName $lastNamt"; $name = $_POST["name"]; $siteArea = $_POST["siteArea"]; $problem = $_POST["problem"]; $email = $_POST["email"]; $comment = $_POST["comment"]; //--------------------------------------------------Main Message------------------------------------------////// $message = " Dear Dean, My name is $name I have been having a good like though you dating site and I come across this problem which is located in the $siteArea. I found the problem being $problem, I will try to explain a bit better for you about the problem that I have come across. $comment Kind regards $name Email: $email "; $ok = mail($to, $subject,$message ); } ?>[/php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Sending a Technical Message</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="robots" content="noindex" />
<meta name="robots" content="nofollow" />
</head><body class="mainB" leftmargin="1" topmargin="1" bgproperties="fixed" marginwidth="0">
<?php
If(empty($errors)=== false){?>
<ol>
<?php
foreach ($errors as $error){
echo "<li>", $error,"</li>";
}
?>
</ol>
<?php
}else{
if(isset ($ok)) {
$ok;
}
}
?>
<table width="75%" align="center" border="0"><form action="" method="post" name="feedback">
<tr>
<td> <table width="88%" border="0" align="center" cellpadding="2" cellspacing="3" bordercolor="#FF0066">
<tr bordercolor="#FF00FF">
<td align="right"><label for="name" class="dateFormFieldNames">Name</label><br><font class="red">Required</font></td>
<td width="79%"><input name="name" id="name" size="16" maxlength="16" class="select2" placeholder="Enter your name" />
</td>
</tr>
<tr bordercolor="#FF00FF">
<td width="21%" align="right"><label for="siteArea" class="dateFormFieldNames">Site earea</label><br><font class="red">Required</font></td>
<td colspan="3"> <div>
<select name="siteArea" id="siteArea" class="select">
<option value="" selected>Select Site
Area</option>
<option value="My Full Bio">My Full Bio</option>
<option value="Image Gallary">Image Gallary</option>
<option value="Send me a message">Send me a message</option>
<option value="Techical Issues">Techical Issues</option>
</select>
</div>
</td>
</tr>
<tr>
<td align="right"><label for="problem" class="dateFormFieldNames">Problems</label><br><font class="red">Required</font></td>
<td colspan="3"><div>
<select name="problem" id="problem" class="select">
<option value="" selected>Select the Problem</option>
<option value="A Broken link">A Broken link</option>
<option value="Page(s) missing">Page(s) missing</option>
<option value="Photo(s) missing">Photo(s) missing</option>
<option value="Link(s) not working">Link(s) not working</option>
<option value="other">>other</option>
</select>
</div></td>
</tr>
<tr bordercolor="#FF00FF">
<td align="right" bordercolor="#FF00FF" ><label for="email" class="dateFormFieldNames">Email Address</label><br><font class="red">Required</font></td>
<td colspan="3"><input name="email" type="text" id="email" class="email" placeholder="Enter your email address" /></td>
</tr>
<tr>
<td rowspan="2" align="right"><label for="explenation" class="dateFormFieldNames">Explenation</label><br><font class="red">Required</font></td>
<td colspan="3">Please explain in further detail what the problem
maybe and where it is or I have not listed any of the problems
above. Please tell me what they are </td>
</tr>
<tr>
<td colspan="3"><textarea name="comment" cols="50" rows="5" placeholder="Enter in your best explaination to where the problem is and what the problem is"></textarea> </td>
</tr>
<tr bordercolor="#FF00FF">
<td colspan="4" align="center" valign="middle" ><input type="submit" name="submit" value="Submit"/>
</td>
</tr>
</table>
<br>
</form>
</td></tr>
</table>
</html>
</body>