Jump to content

PHP Form, Please I need a correction


ijezie

Recommended Posts

I have a Request form like this:

 

Catergory,

Number of Bedrooms,

Budget,

Location

Comments,

Name,

Email,

Phone no.

 

My Php code is:

 

<?phpif(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "iconabel3@gmail.com"; $email_subject = "Property Request"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['category']) || !isset($_POST['type']) || !isset($_POST['bedrooms']) || !isset($_POST['budget']) || !isset($_POST['location']) || !isset($_POST['comments']) || !isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['telephone'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $category = $_POST['category']; // required $type = $_POST['type']; // required $bedrooms = $_POST['bedrooms']; // required $budget = $_POST['budget']; // required $location = $_POST['location']; // required $comments = $_POST['comments']; // required $name = $_POST['name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$type)) { $error_message .= 'The Type you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$bedrooms)) { $error_message .= 'The Number of rooms you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$budget)) { $error_message .= 'The Amount you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$location)) { $error_message .= 'The Location you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(!preg_match($string_exp,$name)) { $error_message .= 'The Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$telephone)) { $error_message .= 'The Phone Number you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email = "Form details below.nn"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Category: ".clean_string($category)."n"; $email_message .= "Type: ".clean_string($type)."n"; $email_message .= "Bedrooms: ".clean_string($bedrooms)."n"; $email_message .= "Budget: ".clean_string($budget)."n" $email_message .= "Location: ".clean_string($location)."n" $email_message .= "Comments: ".clean_string($comments)."n" $email_message .= "name: ".clean_string($name)."n" $email_message .= "Email: ".clean_string($email)."n"; $email_message .= "Telephone: ".clean_string($telephone)."n"; // create email headers$headers = 'From: '.$email_from."rn".'Reply-To: '.$email_from."rn" .'X-Mailer: PHP/' . phpversion();@mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> <h2> Thank you for contacting us. We will get in touch with you very soon. </h2> <?php}?>

 

 

When this form is submitted, it will show this error:

 

Parse error: syntax error, unexpected '$email_message' (T_VARIABLE) in /home/vhosts/mysitename.com/send.php on line 209

 

 

 

Pls help me

Edited by ijezie
Link to comment
Share on other sites

These line of codes seem not to be closed with semi-colon ( ; )

 $email_message .= "Budget: ".clean_string($budget)."n"    $email_message .= "Location: ".clean_string($location)."n"    $email_message .= "Comments: ".clean_string($comments)."n"    $email_message .= "name: ".clean_string($name)."n"
Edited by Don Jajo
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...