acarder488 Posted December 10, 2013 Share Posted December 10, 2013 I am trying to validate my form and then send a message back to the submitter and then send an email to me with the information the submitter inputed. <?php include_once("analyticstracking.php") ?> <?php include_once("analyticstracking1.php") ?> <?php include_once('init.php'); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); }; if(isset($_POST['submit'])) { if (!$_POST['fname'] ) { $mes1='Please enter your First Name';} elseif (!$_POST['lname'] ) { $mes2='Please enter your Last Name';} elseif (!$_POST['street_address'] ) { $mes3='Please enter your Street Address';} elseif (!$_POST['city'] ) { $mes4='Please enter your City';} elseif (!$_POST['state'] ) { $mes5='Please enter your State';} elseif (!$_POST['zip_code'] ) { $mes6='Please enter your Zip Code';} elseif (!$_POST['phone'] ) { $mes7='Please enter your Phone Number';} elseif (!$_POST['department'] ) { $mes9='Please enter your Department';} elseif (!$_POST['email'] ) { $mes10='Please enter your Email Address';} elseif (!$_POST['level']) { $mes12='Please select a Level Of Training';} else { echo " Thank you $_POST[fname] !! Your registration has been submitted!!"; && $sendEmail; } } if(isset($_POST['submit'])) { // validate a phone number if(preg_match("/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/", $_POST['phone'])); // $phone is valid else echo $mes8= 'invalid phone number'; if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { // The email address is not valid echo $mes11= 'invalid email entered';}} $sendEmail= $to = ' webmaster@ottawa-glandorfems.org'; $subject= 'Regisration from $fname'; $fname= $_POST['fname']; $lname= $_POST['lname']; $email= $_POST['email']; $street_address= $_POST['$street_address']; $city= $_POST['city']; $state= $_POST['state']; $zip_code= $_POST['zip_code']; $phone= $_POST['phone']; $department= $_POST['department']; $level= $_POST['level']; $message=<<<EMAIL My name is $fname. $lname, my email is $email. My address is $stree_address . $city . , $state . $zip_code. My phone number is $phone. I work for $department and my level of training is $level. EMAIL; $header = '$email'; mail to($to, $subject, $message, $additional_headers); if (isset($_POST['fname'], $_POST['lname'], $_POST['phone'], $_POST['street_address'], $_POST['city'], $_POST['state'], $_POST['zip_code'], $_POST['department'], $_POST['email'], $_POST['level'])) { $fname = mysqli_real_escape_string ($conn, trim($_POST['fname'])); $lname = mysqli_real_escape_string ($conn, trim($_POST['lname'])); $phone = mysqli_real_escape_string ($conn, trim($_POST['phone'])); $street_address = mysqli_real_escape_string ($conn, trim($_POST['street_address'])); $city = mysqli_real_escape_string ($conn, trim($_POST['city'])); $state = mysqli_real_escape_string ($conn, trim($_POST['state'])); $zip_code = mysqli_real_escape_string ($conn, trim($_POST['zip_code'])); $department = mysqli_real_escape_string ($conn, trim($_POST['department'])); $email = mysqli_real_escape_string ($conn, trim($_POST['email'])); $level = mysqli_real_escape_string ($conn, trim($_POST['level'])); $query ="INSERT INTO oktoberfesttest2014 SET First_Name='{$fname}', Last_Name='{$lname}', Phone='{$phone}', Address='{$street_address}', City='{$city}', State='{$state}', Zip_Code='{$zip_code}', Department='{$department}', Email_Address='{$email}', Level_of_Training='{$level}'"; mysqli_query($conn, $query); //if (!mysqli_query($conn, $query)) { //printf("Errormessage: %s\n", mysqli_error($conn)); //}; } ?> <!DOCTYPE html> <html> <head> <title>Registration form for Octoberfest With O-G EMS 2013</title> </head> <body bgcolor="#084B8A"> <br><div align="center"><img id="Oktoberfest Logo" src="/pics/oktoberfestweb.jpg" border="5" height="200" width="250"><br><br><table style="background-color: beige; border: 1px dashed #999"><tr><td> <center><form action="" method="post"> <p><center>REGISTRATION FORM</center></p> First Name:<input type="text" name="fname" placeholder="First name" size="25" > <p> <b><?php echo "$mes1"; ?></b></p> <p>Last Name:<input type="text" name="lname" size="25" placeholder="Last Name" /> </p><p><b><?php echo "$mes2";?></b> </p> <p>Phone Number:<input type="text" name="phone" placeholder="Phone Number (xxx-xxx-xxxx)" size="30" /></p><p><b><?php echo "$mes7";?><?php echo "$mes8";?></b> </p> <p>Address:<input type="text" name="street_address" size="30" placeholder="Street Address (P.O. Box)" /><p><b><?php echo "$mes3";?></b> </p><input type="text" name="city" size="10" placeholder="City" /><p><b><?php echo "$mes4";?><b> </p><input type="text" placeholder="State" name="state" size="5" /><p><b><?php echo "$mes5";?></b> </p><input type="text" name="zip_code" size="10" placeholder="Zip Code" /><p><b><?php echo "$mes6";?></b> </p> <p>Department:<input type="text" name="department"size="25" placeholder="Department/Agency" /></p><p><b><?php echo "$mes9";?></b> </p> <p>Email Address:<input type="text" name="email" size="40" placeholder="Email Address" /></p></center><p><b><?php echo "$mes10"; ?><?php echo "$mes11";?></b> </p> <fieldset><legend><b>LEVEL OF TRAINING</b></legend> <p><b>(PLEASE NOTE IF YOU HAVE MULTIPLE LEVELS...<br>PLEASE CHOOSE THE ONE YOUR WILL BE ATTENDING FOR)</b></br><p><b><?php echo "$mes12";?></b> </p> <input type="radio" name="level" value="EMR">EMR</br> <input type="radio" name="level" value="EMT-B">EMT-B</br> <input type="radio" name="level" value="EMT-I">EMT-I</br> <input type="radio" name="level" value="EMT-P">EMT-P</br> <input type="radio" name="level" value="Nurse">Nurse</br></p></fieldset> <input type="submit" name="submit" value="Register"><td align="left" valign="bottom"></form><table><tr> <fieldset> <legend><b>If you are not a Putnam County Employee please pay HERE!</b></legend> <form action="https://www.paypal.com/cgi-bin/webscr" target ="_blank" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="V9XZ2NSAT5BWA"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form></tr> </table> </fieldset> </td> </form></td></tr></table> </body> </html> error given is on line 53...I have given my entire html/php for this page. Here is the error I receive.....Parse error: syntax error, unexpected T_BOOLEAN_AND in /home/a9035067/public_html/oktoberfestr12.php on line 53. Thanks for any help. Quote Link to comment Share on other sites More sharing options...
PravinS Posted December 10, 2013 Share Posted December 10, 2013 (edited) check this line echo " Thank you $_POST[fname] !! Your registration has been submitted!!"; && $sendEmail; remove "&& $sendEmail;" if you want to concat $sendEmail, then you can use like this echo " Thank you $_POST[fname] !! Your registration has been submitted!!".$sendEmail; Edited December 10, 2013 by PravinS Quote Link to comment Share on other sites More sharing options...
acarder488 Posted December 10, 2013 Author Share Posted December 10, 2013 Ok thanks!! Now I am getting no errors and it is going to my sql but I am still not receiving an email. Quote Link to comment Share on other sites More sharing options...
PravinS Posted December 10, 2013 Share Posted December 10, 2013 check this line mail to($to, $subject, $message, $additional_headers); for this refer http://php.net/manual/en/function.mail.php Quote Link to comment Share on other sites More sharing options...
acarder488 Posted December 10, 2013 Author Share Posted December 10, 2013 $sendEmail= $to = 'webmaster@ottawa-glandorfems.org'; $subject= 'Registration from $fname'; $fname= $_POST['fname']; $lname= $_POST['lname']; $email= $_POST['email']; $street_address= $_POST['$street_address']; $city= $_POST['city']; $state= $_POST['state']; $zip_code= $_POST['zip_code']; $phone= $_POST['phone']; $department= $_POST['department']; $level= $_POST['level']; $message=<<<EMAIL "My name is $fname . $lname , my email is $email . \r\n My address is $street_address . $city . , $state . $zip_code . \r\n My phone number is $phone . I work for $department and my level of training is $level . \r\n" EMAIL; $header = '$email'; mail($to, $subject, $message, $header); Ok I saw the Sheader issue. Is there something else I am missing? I also added the \r\n not sure if it is needed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.