jharrisonweb Posted February 20, 2014 Share Posted February 20, 2014 Hey all I'm having trouble getting a form to email me when it's submitted. the url is HarrisonAndSonsConstruction.net/contact.html I have a form in the footer that works and I copied most of the code, changing names. I'm not sure why its not working. It will send me an email, but it seems like the variables aren't being loaded, I'm just getting a blank email. This is the form html <form action="contact.php" id='contContact' class='container'> <section class='col-1-3 module'> <input type="text" name="conName" id="conName" placeholder="Name:"> <input type="email" name="conEmail" id="conEmail" placeholder="Email:"> <input type="phone" name="conPhone" id="conPhone" placeholder="Phone:"> <br><input name="Submit" type="submit" value="Send" id="submit"> </section> <section class='col-1-3 module'> <textarea name="conEssay" id="conEssay" placeholder="Message:"></textarea> </section> <section class='col-1-3 last module'> <h3>Address</h3> <h5>Oswego, IL</h5> <h3>Phone</h3> <h5>(331)454-6044</h5> <h3>Email</h3> <h5>RndyHarrison@gmail.com</h5> </section> </form> And the php <?php $conName_field = $_POST['conName']; $conEmail_field = $_POST['conEmail']; $conPhone_field = $_POST['conPhone']; $conMessage = $_POST['#conEssay']; $email_to = 'jharrisonweb@gmail.com'; $subject = 'Message from OswegoBasementRemodeling.com '.$conName_field; $Header = "MIME-Version: 1.0\r\n"; $Header .= "Content-type: text/html; charset=iso-8859-1\r\n"; $header .= 'From: '.$conEmail_field."\r\n"; $header .= 'Reply-To: '.$conEmail_field."\r\n"; $body = 'From: '.$conName_field."\n"; $body .= 'Email: '.$conEmail_field."\n"; $body .= 'Phone: '.$conPhone_field."\n"; $body .= 'Message: '.$conMessage."\n"; $mail_status = mail($email_to, $subject, $body, $headers); if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('Thank you for the message. We will contact you shortly.'); window.location = 'index.html'; </script> <?php } else { ?> <script language="javascript" type="text/javascript"> // Print a message alert('Message failed. Please, send an email to RndyHarrison@gmail.com'); // Redirect to some page of the site. You can also specify full URL, e.g. http://template-help.com window.location = 'index.html'; </script> <?php } ?> Any help would be much appreciated Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted February 20, 2014 Share Posted February 20, 2014 your form tag doesn't have a method attribute and the default when a method isn't specified is to use the get method. Quote Link to comment Share on other sites More sharing options...
Solution WebStyles Posted February 20, 2014 Solution Share Posted February 20, 2014 what mac_gyver is telling you is that you should change your first line (the <form> element) to include a sending method like this: <form action="contact.php" id='contContact' class='container' method="POST"> hope this helps Quote Link to comment Share on other sites More sharing options...
jharrisonweb Posted February 20, 2014 Author Share Posted February 20, 2014 That did it. I knew it was going to be something simple that I should have seen. You saved me hours and smashing my face into the keyboard, thank you very much 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.