sciencechick
New Member
i try to validate form..if i leave off the "php" file and validate w/external js file, it works fine..when i put in the php, i get "parse error on line 22".it is the line "if(isset($_POST['email'])) {\par" of this section :: \[code\]<?php\parif(isset($_POST['email'])) \{\par \par // EDIT THE 2 LINES BELOW AS REQUIRED\par $email_to = 'xxx.com';\par $email_subject = "xxxxxx Comments";\par \[/code\]i cant understand why..help is greatly appreciated..thanx` .. this is the full php file:: \[code\]{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Courier New;}{\f1\fswiss\fcharset0 Arial;}}{\*\generator Msftedit 5.41.15.1512;}\viewkind4\uc1\pard\f0\fs20\par Send_Questions.php \parHTML document text\par<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\par<html xmlns="http://www.w3.org/1999/xhtml">\par<head>\par<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\par<title>Untitled Document</title>\par<style type="text/css" media="all">@import "css/master.css";\par</style>\par<script src="http://stackoverflow.com/questions/15796169/javascript/contact.js" type="text/javascript"></script></head>\par\par<body>\par\par<?php\parif(isset($_POST['email'])) \par // EDIT THE 2 LINES BELOW AS REQUIRED\par $email_to = 'xxx.com';\par $email_subject = "xxxComments";\par \par function died($error) // your error code can go here\par echo "We are very sorry, but there were error(s) found with the form you submitted. ";\par echo "These errors appear below.<br /><br />";\par echo $error."<br /><br />";\par echo "Please go back and fix these errors.<br /><br />";\par die();\par \}\par \par // validation expected data exists\par if(!isset($_POST['name']) ||\par /*!isset($_POST['last_name']) || */\par !isset($_POST['email']) ||\par /*!isset($_POST['telephone']) || */\par !isset($_POST['comments']) \{\par died('We are sorry, but there appears to be a problem with the form you submitted.'); \par \}\par \par $name = $_POST['name']; // not required\par /*$last_name = $_POST['last_name']; // required */\par $email_from = $_POST['email']; // required\par /* $telephone = $_POST['telephone']; // not required */\par $comments = $_POST['comments']; // required\par \par $error_message = "";\par $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\\.[A-Za-z]\{2,4\}$/';\par if(!preg_match($email_exp,$email_from)) \{\par $error_message .= 'The Email Address you entered does not appear to be valid.<br />';\par \}\par $string_exp = "/^[A-Za-z .'-]+$/";\par if(!preg_match($string_exp,$name)) \{\par $error_message .= 'The Name you entered does not appear to be valid.<br />';\par \}\par /* if(!preg_match($string_exp,$last_name)) \{\par $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; */\par \}\par if(strlen($comments)) < 2) \{\par $error_message .= 'The Comments you entered do not appear to be valid.<br />';\par \}\par if(strlen($error_message)) > 0) \{\par died($error_message);\par \}\par $email_message = "Form details below.\\n\\n";\par \par function clean_string($string) \{\par $bad = array("content-type","bcc:","to:","cc:","href");\par return str_replace($bad,"",$string);\par \}\par \par $email_message .= "Name: ".clean_string($name)."\\n";\par /*$email_message .= "Last Name: ".clean_string($last_name)."\\n"; */\par $email_message .= "Email: ".clean_string($email_from)."\\n";\par /*$email_message .= "Telephone: ".clean_string($telephone)."\\n"; */\par $email_message .= "Comments: ".clean_string($comments)."\\n"; \par \par// create email headers\par$headers = 'From: '.$email_from."\\r\\n".\par'Reply-To: '.$email_from."\\r\\n" .\par'X-Mailer: PHP/' . phpversion();\par@mail($email_to, $email_subject, $email_message, $headers); \par?>\par \par<!--include your own success html here -->\par<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\par "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\par<html>\par\par<head>\par\par<meta http-equiv="Refresh" content="5; URL=http://www.kcorchidshow.org/index.html"> \par <title>OSGKC orchid show</title>\par <meta http-equiv="Content-Language" content="en-us" />\par <meta http-equiv="imagetoolbar" content="no" />\par \par <meta name="MSSmartTagsPreventParsing" content="true" />\par\par <meta name="description" content="Orchid Society of Greater Kansas City presents annual orchid show in February, 2012, at American Royal Center, Kansas City, MO. " />\par\par <meta name="keywords" content="orchids, Orchid Society of Greater Kanasas City, Show, Orchid show, Orchid judging, Kansas, American Royal Center" />\par<style type="text/css" media="all">@import "css/master.css";\par</style>\par</head>\par\par<body> \par<p><div id="textbox"><br><br>\par\par<center><h1>Thank you for contacting us. <br />\parWe will be in touch with you very soon.</h1>\par\par<br><br> \par\parPlease wait 5 seconds and you will be transferred to the next page or <a href=http://www.kcorchidshow.org/index.html><font color="#0000ff">click here</font></a> to go now!</center>\par\par<p><center>Please visit our website <a href="http://xxx.org/"><i>www.xxx.org</i></a> to learn more <br />\par about the xxxCity</center>\par<p> </p>\par</div> \par</div>\par</div> \par</body>\par</html>\par \par<?php\par \{\par \}\par?>\par\par</body>\par</html>\par\f1\par}?\[/code\]