aelouch Posted November 19, 2013 Share Posted November 19, 2013 Hi All I am having problem sending of my contact form, please could someone help to find out where I am going wrong. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Form Data ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ <form id="contact-form" name="contactform" method="post" enctype="multipart/form-data" form action="html_form_send.php"> <fieldset> <label><span class="text-form">Name:</span><input name="name" type="text" /></label> <label><span class="text-form">Email:</span><input name="email" type="text" /></label> <label><span class="text-form">Phone:</span><input name="phone" type="text" /></label> <div class="wrapper"><span class="text-form">Comments:</span><textarea></textarea></div> <div class="buttons"> <a class="button" href="#" onClick="document.getElementByID('contact-form').reset()">Clear</a> <a class="button" href="#" onClick="document.getElementByID('contact-form').submit()">Send</a> </div> </fieldset> </form> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ html_form_send.php ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title></title> </head> <body> <p style="text-align: center"><?php if(isset($_POST['email'])) { // CHANGE THE TWO LINES BELOW $email_to = "sales@ltraffic.co.uk"; $email_subject = "King of The Spring- Website Contact Form"; 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['name']) || !isset($_POST['email']) || !isset($_POST['phone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['phone']; // 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,$name)) { $error_message .= 'The 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 .= "Name: ".clean_string($name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Phone: ".clean_string($phone)."\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); ?> <img border="0" height="56" src="logo.png" width="288" /></p> <p style="text-align: center"><span style="font-size: 20px">Thank you for contacting us. We will be in touch with you very soon.</span></p> <p> </p> <p> </p> <p><center><?php }echo "<h1>Success</h1>"; echo "<p>We are now redirecting you to the King of the Spring Homepage</p>"; echo "<meta http-equiv='refresh' content='2;index.html' />"; die(); ?></p> </body> </html> Many Thanks Ant Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted November 19, 2013 Share Posted November 19, 2013 change this: <form id="contact-form" name="contactform" method="post" enctype="multipart/form-data" form action="html_form_send.php"> to this: <form id="contact-form" name="contactform" method="post" enctype="multipart/form-data" action="html_form_send.php"> Quote Link to comment Share on other sites More sharing options...
aelouch Posted November 19, 2013 Author Share Posted November 19, 2013 I have changed this and it is still not working? Any more ideas. Many Thanks Anthony Quote Link to comment Share on other sites More sharing options...
aelouch Posted November 19, 2013 Author Share Posted November 19, 2013 any help would be great! Thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted November 19, 2013 Share Posted November 19, 2013 Define "not working". what is it doing that it shouldn't do? what is it not doing that it should do? Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted November 20, 2013 Share Posted November 20, 2013 Side note: PHP provides a function for validating email addresses: http://php.net/manual/en/filter.examples.validation.php Quote Link to comment Share on other sites More sharing options...
jasonk Posted November 20, 2013 Share Posted November 20, 2013 Good day guys i have be struggling for 2 weeks getting form data to email and to send to the database table. the form is in HTML , but i need php script to send the form data to mail and mysql database. i am not good in php , can someone please help , below is my html code <!DOCTYPE HTML><html><head><meta http-equiv= "Content-Type" content="text/html; charset=UTF-8"><title></title><style type="text/css">body{margin: 0;padding: 0;background-color: #FFFFFF;color: #000000;}</style><style type="text/css">a{color: #0000FF;text-decoration: underline;}a:visited{color: #800080;}a:active{color: #FF0000;}a:hover{color: #0000FF;text-decoration: underline;}</style><style type="text/css">#wb_Form1{background-color: #FAFAFA;border: 0px #000000 solid;}#wb_Text1{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text1 div{text-align: left;}#Editbox1{border: 1px #A9A9A9 solid;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;background-color: #FFFFFF;color :#000000;font-family: 'Trebuchet MS';font-size: 13px;padding: 1px 1px 1px 1px;text-align: left;vertical-align: middle;}#wb_Text2{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text2 div{text-align: left;}#Editbox2{border: 1px #A9A9A9 solid;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;background-color: #FFFFFF;color :#000000;font-family: 'Trebuchet MS';font-size: 13px;padding: 1px 1px 1px 1px;text-align: left;vertical-align: middle;}#wb_Text3{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text3 div{text-align: left;}#Editbox3{border: 1px #A9A9A9 solid;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;background-color: #FFFFFF;color :#000000;font-family: Arial;font-size: 13px;text-align: left;vertical-align: middle;}#wb_Text5{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text5 div{text-align: left;}#Combobox1{border: 1px #A9A9A9 solid;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;background-color: #FFFFFF;color: #000000;font-family: 'Trebuchet MS';font-size: 13px;}#wb_Text6{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text6 div{text-align: left;}#wb_Text7{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text7 div{text-align: left;}#wb_Text8{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text8 div{text-align: left;}#wb_Text9{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text9 div{text-align: left;}#wb_Text10{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text10 div{text-align: left;}#wb_Text11{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text11 div{text-align: left;}#wb_Text12{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text12 div{text-align: left;}#wb_Text13{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text13 div{text-align: left;}#Button1{border: 1px #D3D3D3 solid;background-color: #F0F0F0;color: #000000;font-family: 'Trebuchet MS';font-weight: bold;font-size: 13px;-moz-box-shadow: 0px 0px 2px #000000;-webkit-box-shadow: 0px 0px 2px #000000;box-shadow: 0px 0px 2px #000000;}#Image1{border: 0px #000000 solid;}#wb_Text14{background-color: transparent;border: 0px #000000 solid;padding: 0;text-align: left;}#wb_Text14 div{text-align: left;}</style></head><body><div id="wb_Form1" style="position:absolute;left:26px;top:99px;width:735px;height:749px;z-index:23;"><form name="Feedback_Form" method="post" action="" accept-charset="UTF-8" target="_blank" id="Form1"><div id="wb_Text1" style="position:absolute;left:116px;top:23px;width:84px;height:18px;z-index:0;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:13px;">First Name</span></div><input type="text" id="Editbox1" style="position:absolute;left:210px;top:15px;width:196px;height:21px;line-height:21px;z-index:1;" name="firstname" value="" maxlength="25" autocomplete="off"><div id="wb_Text2" style="position:absolute;left:116px;top:58px;width:84px;height:18px;z-index:2;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:13px;">Last Name</span></div><input type="text" id="Editbox2" style="position:absolute;left:210px;top:50px;width:196px;height:21px;line-height:21px;z-index:3;" name="lastname" value="" maxlength="30" autocomplete="off"><div id="wb_Text3" style="position:absolute;left:116px;top:92px;width:84px;height:18px;z-index:4;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:13px;">Department</span></div><input type="text" id="Editbox3" style="position:absolute;left:210px;top:84px;width:198px;height:23px;line-height:23px;z-index:5;" name="department" value="" autocomplete="off"><div id="wb_Text5" style="position:absolute;left:116px;top:124px;width:84px;height:18px;z-index:6;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:13px;">Technicians</span></div><select name="technician" size="1" id="Combobox1" style="position:absolute;left:210px;top:118px;width:200px;height:25px;z-index:7;"><option selected></option><option value="Carlo Dreyer">Carlo Dreyer</option><option value="Gillian Williams">Gillian Williams</option><option value="Jason Kleinhans">Jason Kleinhans</option><option value="Marcello Thomas">Marcello Thomas</option><option value="Philip Mason ">Philip Mason </option><option value="Valencia Cleinwerck ">Valencia Cleinwerck</option></select><div id="wb_Text7" style="position:absolute;left:116px;top:193px;width:84px;height:18px;z-index:8;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:13px;">Good</span></div><input type="radio" id="RadioButton1" name="q[1]" value="Good" checked style="position:absolute;left:199px;top:193px;z-index:9;"><div id="wb_Text8" style="position:absolute;left:116px;top:220px;width:84px;height:18px;z-index:10;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:13px;">Satisfied</span></div><input type="radio" id="RadioButton2" name="q[1]" value="Satisfied" style="position:absolute;left:199px;top:219px;z-index:11;"><div id="wb_Text9" style="position:absolute;left:116px;top:246px;width:84px;height:18px;z-index:12;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:13px;">Unsatisfied</span></div><input type="radio" id="RadioButton3" name="q[1]" value="Unsatisfied" style="position:absolute;left:199px;top:245px;z-index:13;"><div id="wb_Text10" style="position:absolute;left:115px;top:275px;width:369px;height:50px;z-index:14;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:15px;"><strong>How would you rate our service ? </strong></span><span style="color:#000000;font-family:'Times New Roman';font-size:16px;"><br></span></div><div id="wb_Text11" style="position:absolute;left:115px;top:336px;width:84px;height:18px;z-index:15;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:13px;">Good</span></div><input type="radio" id="RadioButton4" name="q[2]" value="Good" checked style="position:absolute;left:199px;top:334px;z-index:16;"><div id="wb_Text12" style="position:absolute;left:115px;top:363px;width:84px;height:18px;z-index:17;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:13px;">Satisfied</span></div><input type="radio" id="RadioButton5" name="q[2]" value="Satisfied" style="position:absolute;left:199px;top:360px;z-index:18;"><div id="wb_Text13" style="position:absolute;left:116px;top:392px;width:84px;height:18px;z-index:19;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:13px;">Unsatisfied</span></div><input type="radio" id="RadioButton6" name="q[2]" value="Unsatisfied" style="position:absolute;left:199px;top:388px;z-index:20;"><input type="submit" id="Button1" name="Submit" value="Send" style="position:absolute;left:235px;top:442px;width:96px;height:25px;z-index:21;"><div id="wb_Text6" style="position:absolute;left:116px;top:165px;width:386px;height:20px;z-index:22;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:15px;"><strong>How was your experience with the technician ?</strong></span></div></form></div><div id="wb_Image1" style="position:absolute;left:27px;top:13px;width:122px;height:60px;z-index:24;"></div><div id="wb_Text14" style="position:absolute;left:215px;top:52px;width:391px;height:35px;z-index:25;text-align:left;"><span style="color:#000080;font-family:'Trebuchet MS';font-size:27px;"><strong>Feedback Form</strong></span></div></body></html> Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted November 20, 2013 Share Posted November 20, 2013 Define "not working". what is it doing that it shouldn't do? what is it not doing that it should do? ^^^ What he wrote. You showed us a huge form with piles of css style. You need to explain what your issue is. Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted November 20, 2013 Share Posted November 20, 2013 I can confirm that your form part is fine and sends data. If you are using the same php code as your first post, you never use email in your form therefore nothing else in your php script will work if(isset($_POST['email'])) { Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted November 20, 2013 Share Posted November 20, 2013 @jasonk - When posting code, please surround it with tags. It makes the post and code easier to read. Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted November 20, 2013 Share Posted November 20, 2013 Sorry, I just noticed that jasonk isn't the OP. @jasonk - Please don't hijack someone else's thread. If you have a question, please start a new one. @aelouch - Sorry about any confusion. Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted November 20, 2013 Share Posted November 20, 2013 Ha, didn't even realize was a different person cyberrobot 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.