sallen5280 Posted January 10, 2012 Share Posted January 10, 2012 Hello, everyone. Thank you so much for taking the time to look at my post. I know very little about php and created a contact form for my Web site through a tutorial that I found online. It ALMOST works. The only problem is that the actual data that is entered into the form is not being passed through to the email that is sent to me after the "Submit" button is clicked. On the email that comes through to me, it simply says: First Name: Last Name: Email: Phone: Comments: I'm thinking it must be a minor syntax error, but I can't find it. The URL of the contact form is http://www.scottallenresume.com/contact.html. The code for the form processor is: <?php /* Subject and Email Variables */ $emailSubject = 'Scott Allen Resume Web Inquiry'; $webMaster = '[email protected]'; /* Gathering Data Variables */ $first_nameField = $_POST['first_name']; $last_nameField = $_POST['last_name']; $email_fromField = $_POST['email_from']; $telephoneField = $_POST['telephone']; $commentsField = $_POST['comments']; $body = <<<EOD <br><hr><br> First Name: $first_name <br> Last Name: $last_name <br> Email: $email_from <br> Phone: $telephone <br> Comments: $comments <br> EOD; $headers = "From: $email_from\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results Rendered as HTML */ $theResults = <<<EOD <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="icon" type="image/jpeg" href="favicon-02.jpg"> <!-- For good browsers. --> <link rel="SHORTCUT ICON" href="favicon.jpg"/> <!-- For Internet Explorer--> <title>Resume of Scott S Allen, Search Engine Optimizer and Search Engine Marketer</title> <link href="css/style.css" rel="stylesheet" type="text/css" media="all" /> <link href="font/stylesheet.css" rel="stylesheet" type="text/css" media="all" /> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-28021886-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </head> <body> <div id="main"><!-- Closed --> <div id="header"><!-- Closed --> <div id="header-main"><!-- Closed --> <div id="header-sup"><!--Closed --> <h1><a href="index.html" class="logo"></a></h1> <ul id="menu"> <li><a href="index.html"><span>HOME</span></a></li> <li><a href="about.html"><span>ABOUT</span></a></li> <li><a href="services.html"><span>EXPERIENCE</span></a></li> <li><a href="blog.html"><span>BLOG</span></a></li> <li><a href="contact.html"><span>CONTACT</span></a></li> </ul> </div><!--Close "header-sup" div --> </div><!--Close "header-main" div --> </div><!--Close "header" div --> <!-- ONLY OPEN DIV IS "MAIN" --> <div id="wrap"><!-- Closed --> <div id="wrap-sup"><!-- Closed --> <div id="center"><!-- Closed --> <img src="images/topline.png" alt="" /> <p class="title">Online Resume of Scott Allen</p> <h2>Seeking to make a difference in the world through my knowledge of Search Engine Marketing and Optimization.</h2> <img src="images/btmline.png" alt="" class="btmline" /> </div><!-- Close "center" div --> </div><!--Close "wrap-sup" div --> </div><!-- Close "wrap" div --> <!-- ONLY OPEN DIV IS "MAIN" --> <div id="btm"><!-- Closed --> <div align="center"><!-- Closed --> <br /> <br /> <p class="thankyou">Thank you for taking the time to contact me.<br /> I sincerely hope that you have found my Web site useful. <br /> I will be getting back with you shortly. Thank you again.</p> <br /> <br /> <br /> <br /> <br /> <br /> </div><!-- Close div align center --> <div id="btm-main"><!-- Closed --> <div id="footer"><!-- Closed --> <p>© 2011 Scott Allen. All rights reserved.</p> <ul id="nav"> <li><a href="index.html">Home</a></li> <li class="space">|</li> <li><a href="about.html">About</a></li> <li class="space">|</li> <li><a href="services.html">Experience</a></li> <li class="space">|</li> <li><a href="blog.html">Blog</a></li> <li class="space">|</li> <li><a href="contact.html">Contact</a></li> </ul> </div><!-- Close "footer" div --> </div><!-- Close "btm-main" div --> </div><!-- Close "btm" div --> </div><!-- Close "main" div --> </body> </html> EOD; echo "$theResults"; ?> Any help you can give me would be greatly appreciated. Thank you so much! Scott Quote Link to comment https://forums.phpfreaks.com/topic/254696-form-data-not-going-to-email/ Share on other sites More sharing options...
Psycho Posted January 10, 2012 Share Posted January 10, 2012 The problem looks pretty obvious to me. Here is where you define your variables from the POST data $first_nameField = $_POST['first_name']; $last_nameField = $_POST['last_name']; $email_fromField = $_POST['email_from']; $telephoneField = $_POST['telephone']; $commentsField = $_POST['comments']; Here is where you define the body of the email $body = <<<EOD <br><hr><br> First Name: $first_name <br> Last Name: $last_name <br> Email: $email_from <br> Phone: $telephone <br> Comments: $comments <br> EOD; The variables you set from the POST data ($first_nameField, $last_nameField, $email_fromField, etc.) are not the variables you are using in the body of the email ($first_name, $last_name, $email_from, etc.) Try removing 'Field' at the end of all the variables you are setting from the POST data Quote Link to comment https://forums.phpfreaks.com/topic/254696-form-data-not-going-to-email/#findComment-1306006 Share on other sites More sharing options...
sallen5280 Posted January 10, 2012 Author Share Posted January 10, 2012 Of course. Thank you for your help. The form is working now. Quote Link to comment https://forums.phpfreaks.com/topic/254696-form-data-not-going-to-email/#findComment-1306008 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.