Jump to content

Form Validation is'nt working


ismaZulfiqar

Recommended Posts

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>

Link to comment
Share on other sites

Added the declaration and modified the code, still the same error.

 

// From
$FirstName = $_POST['$FirstName'];
$LastName = $_POST['$LastName'];
$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']) || empty($_POST['$LastName'])) 
	$validationOK=false;

if ($validationOK==false) {
	print "Incomplete submission! You should use your browsers back button, return to the previous page and fill ALL the fields.";
}

 

Where are FirstName and LastName set?

 

$name = $FirstName." ".$LastName;

$header="From: $name <$mail_from>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.