this is the error I get when submitting a form Parse error: syntax error, unexpected '}' in /home/content/64/10360664/html/html_form_send.php on line 1 Here is the code being used. (I know some coding but am still learning a lot. If you can 'dumb down' any responses.... that would be appreciated greatly) <?phpif(isset($_POST['email'])) } // CHANGE THE TWO LINES BELOW $email_to = "applicant@redrivercarclub.com"; $email_subject = "Application for Membership"; 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['date']) || !isset($_POST['name']) || !isset($_POST['address']) || !isset($_POST['address2']) || !isset($_POST['name']) || !isset($_POST['city']) || !isset($_POST['state']) || !isset($_POST['zip']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST[vehicles]) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } // required $date = $_POST['date']; // required $name = $_POST['name']; // required $address = $_POST['address']; // not required $address2 = $_POST['address2']; // required $city = $_POST['city']; // required $state = $_POST['state']; // required $zip = $_POST['zip']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // required $vehicles = $_POST['vehicles']; // not required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name 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(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Date: ".clean_string($date)."\n"; $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "Address: ".clean_string($address)."\n"; $email_message .= "Address2: ".clean_string($address2)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "State: ".clean_string($state)."\n"; $email_message .= "Zip: ".clean_string($zip)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Vehicles: ".clean_string($vehicles)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers$headers = 'From: '.$email_from."\r\n".'Reply-To: '.$email_from."\r\n" .'X-Mailer: PHP/' . phpversion();@mail($email_to, $email_subject, $email_message, $headers); ?> <!-- place your own success html below --> <html> <body> Thank you for submitting your application. We will be in touch with you very soon. <?php}die();?> </body> </html> PHP:
Try this: <?php if(isset($_POST['email'])) { // CHANGE THE TWO LINES BELOW $email_to = "applicant@redrivercarclub.com"; $email_subject = "Application for Membership"; 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['date']) || !isset($_POST['name']) || !isset($_POST['address']) || !isset($_POST['address2']) || !isset($_POST['name']) || !isset($_POST['city']) || !isset($_POST['state']) || !isset($_POST['zip']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST[vehicles]) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } // required $date = $_POST['date']; // required $name = $_POST['name']; // required $address = $_POST['address']; // not required $address2 = $_POST['address2']; // required $city = $_POST['city']; // required $state = $_POST['state']; // required $zip = $_POST['zip']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // required $vehicles = $_POST['vehicles']; // not required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name 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(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Date: ".clean_string($date)."\n"; $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "Address: ".clean_string($address)."\n"; $email_message .= "Address2: ".clean_string($address2)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "State: ".clean_string($state)."\n"; $email_message .= "Zip: ".clean_string($zip)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Vehicles: ".clean_string($vehicles)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers$headers = 'From: '.$email_from."\r\n".'Reply-To: '.$email_from."\r\n" .'X-Mailer: PHP/' . phpversion();@mail($email_to, $email_subject, $email_message, $headers); ?> <!-- place your own success html below --> <html> <body> Thank you for submitting your application. We will be in touch with you very soon. <?php}die();?> </body> </html> PHP:
Copied and pasted the code above and when I submit, I get this: Parse error: syntax error, unexpected '}' in /home/content/64/10360664/html/html_form_send.php on line 130 Am I missing out on something??
Yes. you commented out the close php line. Try this instead: <?php if(isset($_POST['email'])) { // CHANGE THE TWO LINES BELOW $email_to = "applicant@redrivercarclub.com"; $email_subject = "Application for Membership"; 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['date']) || !isset($_POST['name']) || !isset($_POST['address']) || !isset($_POST['address2']) || !isset($_POST['name']) || !isset($_POST['city']) || !isset($_POST['state']) || !isset($_POST['zip']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST[vehicles]) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } // required $date = $_POST['date']; // required $name = $_POST['name']; // required $address = $_POST['address']; // not required $address2 = $_POST['address2']; // required $city = $_POST['city']; // required $state = $_POST['state']; // required $zip = $_POST['zip']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // required $vehicles = $_POST['vehicles']; // not required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name 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(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Date: ".clean_string($date)."\n"; $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "Address: ".clean_string($address)."\n"; $email_message .= "Address2: ".clean_string($address2)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "State: ".clean_string($state)."\n"; $email_message .= "Zip: ".clean_string($zip)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Vehicles: ".clean_string($vehicles)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers$headers = 'From: '.$email_from."\r\n".'Reply-To: '.$email_from."\r\n" .'X-Mailer: PHP/' . phpversion();@mail($email_to, $email_subject, $email_message, $headers); ?> <!-- place your own success html below --> <html> <body> Thank you for submitting your application. We will be in touch with you very soon. <?php } ?> </body> </html> PHP:
Ok. This is almost frustrating Parse error: syntax error, unexpected $end in /home/content/64/10360664/html/html_form_send.php on line 135
Great! Thanks for your help however, now when submit is pressed from the form, a blank page is shown and nothing gets submitted. This I need to correct and then another question: Is there a way to do a redirect after the message has been seen upon confirmation of form submit?