Lori De Posted October 4, 2011 Share Posted October 4, 2011 here's my html form: <form action="contact2.php" method="post" target="_self" id="contactform"> <ol> <li> <label for="name2">Your Name <span class="red">*</span></label> <input id="name2" name="name2" class="text" /> </li> <li> <label for="youremail">Your email <span class="red">*</span></label> <input id="youremail" name="youremail" class="text" /> </li> <li> <label for="company2">Company</label> <input id="company2" name="company2" class="text" /> </li> <li> <label for="subject2">Subject</label> <input id="subject2" name="subject2" class="text" /> </li> <li> <label for="message2">Message <span class="red">*</span></label> <textarea id="message2" name="message2" rows="6" cols="50"></textarea> </li> <li class="buttons"> <input type="image" name="imageField" id="imageField" src="images/send.gif" /> </li> </ol> </form> Here's my php code: <?PHP global $_POST; $name = $_POST["name2"]; $youremail = $_POST["youremail"]; $company = $_POST["company2"]; $subject = $_POST["subject2"]; $message = $_POST["message2"]; $to = "ldemotts@market-johnson.com"; $subject = "Form Submission"; $headers = "From: $youremail\n"; $message = "A visitor to your site has filled out the following information.\n Name: $name2 Email Address: $youremail Company: $company2 Subject: $subject2 Message: $message2"; if (preg_match(' /[\r\n,;\'"]/ ', $_POST['youremail'])) { exit('Invalid Email Address'); } else { mail($to,$subject,$message,$headers); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/248397-my-form-processes-but-none-of-the-information-comes-thru/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 4, 2011 Share Posted October 4, 2011 Remove the following line of code - global $_POST; A) Never use the global keyword, ever. B) Php has got a built-in 'got ya' for you when you use global with one of the super global arrays ($_POST, $_GET, $_SESSION, ...). It creates a whole new array that is empty because it is not tied to the actual super global array. Quote Link to comment https://forums.phpfreaks.com/topic/248397-my-form-processes-but-none-of-the-information-comes-thru/#findComment-1275583 Share on other sites More sharing options...
Lori De Posted October 4, 2011 Author Share Posted October 4, 2011 I took that line out and now I get the senders email address, but nothing else? Quote Link to comment https://forums.phpfreaks.com/topic/248397-my-form-processes-but-none-of-the-information-comes-thru/#findComment-1275589 Share on other sites More sharing options...
Pikachu2000 Posted October 4, 2011 Share Posted October 4, 2011 $name != $name2, etc. Quote Link to comment https://forums.phpfreaks.com/topic/248397-my-form-processes-but-none-of-the-information-comes-thru/#findComment-1275594 Share on other sites More sharing options...
Lori De Posted October 4, 2011 Author Share Posted October 4, 2011 sorry I'm new to this..what exactly am I replacing with $name != $name2 $name = $_POST["name2"]; or Name: $name2 Quote Link to comment https://forums.phpfreaks.com/topic/248397-my-form-processes-but-none-of-the-information-comes-thru/#findComment-1275599 Share on other sites More sharing options...
PFMaBiSmAd Posted October 4, 2011 Share Posted October 4, 2011 != means not equal/not the same as, so $name != $name2 means $name is not the same as $name2 Quote Link to comment https://forums.phpfreaks.com/topic/248397-my-form-processes-but-none-of-the-information-comes-thru/#findComment-1275603 Share on other sites More sharing options...
Lori De Posted October 4, 2011 Author Share Posted October 4, 2011 I understand what your saying, but I don't know what I am supposed to change. Quote Link to comment https://forums.phpfreaks.com/topic/248397-my-form-processes-but-none-of-the-information-comes-thru/#findComment-1275608 Share on other sites More sharing options...
Drummin Posted October 4, 2011 Share Posted October 4, 2011 Notice each of these post values are turned into variables. $name = $_POST["name2"]; $youremail = $_POST["youremail"]; $company = $_POST["company2"]; $subject = $_POST["subject2"]; $message2 = $_POST["message2"]; Make sure these are the same variables you are using for your message. $message = "A visitor to your site has filled out the following information.\n Name: $name Email Address: $youremail Company: $company Subject: $subject Message: $message2" I would then wrap all the php inside a posted value IF condition (usually submit) but in this case the name you're using is imageField. <?PHP IF (isset($_POST['mageField'])){ $name = $_POST["name2"]; $youremail = $_POST["youremail"]; $company = $_POST["company2"]; $subject = $_POST["subject2"]; $message = $_POST["message2"]; $to = "ldemotts@market-johnson.com"; $subject = "Form Submission"; $headers = "From: $youremail\n"; $message = "A visitor to your site has filled out the following information.\n Name: $name Email Address: $youremail Company: $company Subject: $subject Message: $message2"; if (preg_match(' /[\r\n,;\'"]/ ', $_POST['youremail'])) { exit('Invalid Email Address'); } else { mail($to,$subject,$message,$headers); } }//END Bracket for IF (isset($_POST['mageField'])){ ?> Hey I may not have everything 100% here but I hope you get the idea. Quote Link to comment https://forums.phpfreaks.com/topic/248397-my-form-processes-but-none-of-the-information-comes-thru/#findComment-1275612 Share on other sites More sharing options...
Drummin Posted October 4, 2011 Share Posted October 4, 2011 I was on my way out the door when I wrote that last message. Speaking of message, make sure the variable $message2 is the correct one used. My last post should have said. <?PHP IF (isset($_POST['mageField'])){ $name = $_POST["name2"]; $youremail = $_POST["youremail"]; $company = $_POST["company2"]; $subject = $_POST["subject2"]; $message2 = $_POST["message2"]; $to = "ldemotts@market-johnson.com"; $subject = "Form Submission"; $headers = "From: $youremail\n"; $message = "A visitor to your site has filled out the following information.\n Name: $name Email Address: $youremail Company: $company Subject: $subject Message: $message2"; if (preg_match(' /[\r\n,;\'"]/ ', $_POST['youremail'])) { exit('Invalid Email Address'); } else { mail($to,$subject,$message,$headers); } }//END Bracket for IF (isset($_POST['mageField'])){ ?> Quote Link to comment https://forums.phpfreaks.com/topic/248397-my-form-processes-but-none-of-the-information-comes-thru/#findComment-1275669 Share on other sites More sharing options...
Lori De Posted October 4, 2011 Author Share Posted October 4, 2011 Got it! It works beautifully! Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/248397-my-form-processes-but-none-of-the-information-comes-thru/#findComment-1275671 Share on other sites More sharing options...
mikesta707 Posted October 4, 2011 Share Posted October 4, 2011 Glad you got your problem fixed. Marking your topic as solved Quote Link to comment https://forums.phpfreaks.com/topic/248397-my-form-processes-but-none-of-the-information-comes-thru/#findComment-1275672 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.