merkaba Posted February 21, 2010 Share Posted February 21, 2010 I took a send_form_mail.php script someone I work with gave me and I am trying to adapt it to email the results from a customer survey. When the "Submit" button is clicked it returns the following message: "Parse error: syntax error, unexpected '!' in /homepages/29/d245297400/htdocs/tacovia/css/send_survey_email.php on line 14" I am a noob when it comes to php so I might not even be going about this the right way. This was originally a simple script that I am using on the "Contact Us" page and it works just fine. Survey Page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Taco Viá - Overland Park, KS - 913.649.3885</title> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="page"> <div id="header"> </div> <div id="nav"> <ul> <li><a href="http://tacovia.com/css/index.html">Home</a></li> <li><a href="http://tacovia.com/css/menu.html">Menu</a></li> <li><a href="http://tacovia.com/css/stuff.html">Viá Stuff</a></li> <li><a href="http://tacovia.com/css/contact.html">Contact Us</a></li> </ul> </div> <div id="contentsurvey"> <div id="survey"> <table> <FORM name="contactform" METHOD="POST" ACTION="send_survey_email.php"> <p>You understand that this survey pertains only to the Taco Viá at 95th & Antioch in Overland Park, KS.<br> <select name="onlythisstore"> <option value=""></option> <option value="Yes">Yes</option> <option value="No">No</option> </select> </p> <p>Was this your first visit to Taco Viá?<br> <select name="firstvisit"> <option value=""></option> <option value="Yes">Yes</option> <option value="No">No</option> </select> </p> <p>How many times have you been to our store in the past month?<br> <select name="visitslastmonth"> <option value=""></option> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5+">5+</option> </select> </p> <p>What time of the day did you visit?<br> <select name="timeofday"> <option value=""></option> <option value="Lunch">Lunch</option> <option value="Afternoon">Afternoon</option> <option value="Evening">Evening</option> </select> </p> <p>How would you rate our service / friendliness?<br> <select name="servicefriendliness"> <option value=""></option> <option value="Excellent">Excellent</option> <option value="Good">Good</option> <option value="Satisfactory">Satisfactory</option> <option value="Poor">Poor</option> <option value="Very Poor">Very Poor</option> </select> </p> <p>How would you rate our food?<br> <select name="foodrating"> <option value=""></option> <option value="Excellent">Excellent</option> <option value="Good">Good</option> <option value="Satisfactory">Satisfactory</option> <option value="Poor">Poor</option> <option value="Very Poor">Very Poor</option> </select> </p> <p>How would you rate our portion size / value?<br> <select name="portionvalue"> <option value=""></option> <option value="Excellent">Excellent</option> <option value="Good">Good</option> <option value="Satisfactory">Satisfactory</option> <option value="Poor">Poor</option> <option value="Very Poor">Very Poor</option> </select> </p> <p>How would you rate the cleanliness?<br> <select name="cleanliness"> <option value=""></option> <option value="Excellent">Excellent</option> <option value="Good">Good</option> <option value="Satisfactory">Satisfactory</option> <option value="Poor">Poor</option> <option value="Very Poor">Very Poor</option> </select> </p> <p>How can we make your next visit better? (optional)<br> <textarea name="nextvisitbetter" cols="50" rows="10"></textarea> </p> <p> <input type="submit" name="Submit" value="Submit"> <input name="Reset" type="reset" id="Reset" value="Reset"> </p> </form> </table> </div> <div style="clear: both;"> </div> <div id="footer"> Aztec Foods Inc. d.b.a. Taco Viá </div> </div> </body> </html> PHP Script I am using <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "[email protected]"; $email_from = "[email protected]"; $email_subject = "Survey from Taco Viá Website"; // validation expected data exists if(!isset($_POST['onlythisstore']) || !isset($_POST['firstvisit']) || !isset($_POST['visitslastmonth']) || !isset($_POST['timeofday']) !isset($_POST['servicefriendliness']) !isset($_POST['foodrating'] || !isset($_POST['portionvalue']) || !isset($_POST['cleanliness']) || !isset($_POST['nextvisitbetter'])) { died('We are sorry, but there appears to be a problem with the form your submitted.'); } // required $onlythisstore = $_POST['onlythisstore']; $firstvisit = $_POST['firstvisit']; $visitslastmonth = $_POST['visitslastmonth']; $timeofday = $_POST['timeofday']; $servicefriendliness = $_POST['servicefriendliness']; $foodrating = $_POST['foodrating']; $portionvalue = $_POST['portionvalue']; $cleanliness = $_POST['cleanliness']; $nextvisitbetter = $_POST['nextvisitbetter']; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Question1: ".clean_string($onlythisstore)."\n"; $email_message .= "Question2: ".clean_string($firstvisit)."\n"; $email_message .= "Question3: ".clean_string($visitslastmonth)."\n"; $email_message .= "Question4: ".clean_string($timeofday)."\n"; $email_message .= "Question5: ".clean_string($servicefriendliness)."\n"; $email_message .= "Question6: ".clean_string($foodrating)."\n"; $email_message .= "Question7: ".clean_string($portionvalue)."\n"; $email_message .= "Question8: ".clean_string($cleanliness)."\n"; $email_message .= "Question9: ".clean_string($nextvisitbetter)."\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); ?> <!-- include your own success html here --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Taco Viá - Overland Park, KS - 913.649.3885</title> <meta http-equiv="refresh" content="0; URL=http://tacovia.com/css/thankyou2.html"> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="page"> <div id="header"> </div> <div id="nav"> <ul> <li><a href="http://tacovia.com/css/index.html">Home</a></li> <li><a href="http://tacovia.com/css/menu.html">Menu</a></li> <li><a href="http://tacovia.com/css/stuff.html">Viá Stuff</a></li> <li><a href="http://tacovia.com/css/contact.html">Contact Us</a></li> </ul> </div> <div id="contentthankyou"> <div id="contentthankyou_title"> Thank You </div> <br> <div id="contentthankyou_text"> Your email has been sent. </div> </div> <div style="clear: both;"> </div> <div id="footer"> Aztec Foods Inc. d.b.a. Taco Viá </div> </div> </body> </html> <? } ?> Link to comment https://forums.phpfreaks.com/topic/192854-email-survey-results-script/ Share on other sites More sharing options...
merkaba Posted February 23, 2010 Author Share Posted February 23, 2010 Solved (aka noob mistakes): ------------------------------------------------------------------------------- Original: (email isn't a variable on the form) if(isset($_POST['email'])) { Working: if(isset($_POST['onlythisstore'])) { ------------------------------------------------------------------------------- Original: (missing a few important characters...not sure how I didn't see these) // validation expected data exists if(!isset($_POST['onlythisstore']) || !isset($_POST['firstvisit']) || !isset($_POST['visitslastmonth']) || !isset($_POST['timeofday']) !isset($_POST['servicefriendliness']) !isset($_POST['foodrating'] || !isset($_POST['portionvalue']) || !isset($_POST['cleanliness']) || !isset($_POST['nextvisitbetter'])) { died('We are sorry, but there appears to be a problem with the form your submitted.'); } Working: // validation expected data exists if(!isset($_POST['onlythisstore']) || !isset($_POST['firstvisit']) || !isset($_POST['visitslastmonth']) || !isset($_POST['timeofday']) || !isset($_POST['servicefriendliness']) || !isset($_POST['foodrating']) || !isset($_POST['portionvalue']) || !isset($_POST['cleanliness']) || !isset($_POST['nextvisitbetter'])) { died('We are sorry, but there appears to be a problem with the form your submitted.'); } Link to comment https://forums.phpfreaks.com/topic/192854-email-survey-results-script/#findComment-1016842 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.