I am trying to put a check on fields in the form in following code but it always gives Incomplete Submission error.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>BEAU Enquiry</title>
<link href="css/beau-style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h2>Enquiry Submission Status</h2>
<?php
/***************************
* Configuration *
***************************/
// Who should this message be sent to?
$to = "zulfiqar.isma@gmail.com";
// Contact subject
$subject = "BEAU Enquiry Submission";
// Details
$message=Trim(stripslashes($_POST['$detail']));
// Mail of sender
$mail_from= Trim(stripslashes($_POST['$EmailAddress']));
// From
$name = $FirstName." ".$LastName;
$header="From: $name <$mail_from>";
/***************************
* End of Configuration *
***************************/
// Validation
// Check we have recieved post data - don't just send out an empty e-mail
$validationOK=true;
if (empty($mail_from) || empty($message) || empty($_POST['$FirstName']) || $_POST['$LastName'])
$validationOK=false;
if (!$validationOK) {
print "Incomplete submission! You should use your browsers back button, return to the previous page and fill ALL the fields.";
}
// The form passed validation and the message will be sent.
else {
// Build up the message to be sent
$message = "Users IP Address: ".$_SERVER["REMOTE_ADDR"]."\n"; // IP address
$message .= "Submission Date: ".date("d-M-Y")."\n"; // Date of message sending
$message .= "Form Location: ".$_SERVER["HTTP_REFERER"]."\n\n"; // Form the request came from
// Iterate through the data we have recieved and build up the message
while(list($name, $value) = each($_POST)) {
// ensure multiple items from a select box are included correctly.
if (is_array($value)) {
foreach($value as $subvalue) { $newValue .= $subvalue."\n"; } $value = $newValue;
}
// Create an array of strange looking code. If we spot any of these
// anywhere the sender may be up to no good!
$suspiciousCode = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i");
// If we see and suspicious code, replace it with the words '***removed***'
$value = preg_replace($suspiciousCode, "***removed***", $value);
// Append the text to the message
$message .= ucfirst($name).": \t".stripslashes(strip_tags(wordwrap($value,65)))."\n";
}
$send=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "We've recived your information"
if($send){
echo "We've received your enquiry and will get back to you soon!";}
else {
echo "ERROR Sending Form";}
}
?>
</body>
</html>