snottrocket Posted March 16, 2011 Share Posted March 16, 2011 So, I'm working on this contact form for a project. I found a tutorial on building such a form which turned out to be simple enough. It seems to work as far as when I submit, the echo response shows up in the browser window..however, there's no actual email that shows up in my mailbox. Here's the code for the form: <form name="contact" id="contact" method="post" action="mailer.php"> <p> <label for="fullname">Name:</label> <input type="text" name="name" class="txt"> </p> <p> <label for="address"> Property Street Address:</label> <input type="text" name="address" class="txt"> </p> <p> <label for="city">City:</label> <input type="text" name="city" class="txt"> </p> <p> <label for="state">State:</label> <input type="text" name="state" class="txt"> </p> <p> <label for="zip">Zip:</label> <input type="text" name="zip" class="txt"> </p> <p> <label for="owners">Owner(s) of Record:</label> <input type="text" name="owner" class="txt"> </p> <p> <label for="parcel">Parcel ID# (Leave Blank if Unknown):</label> <input type="text" name="parcel" class="txt"> </p> <p> <label for="phone">Phone:</label> <input type="text" name="phone" class="txt"> </p> <p> <label for="email">Email:</label> <input type="text" name="email" class="txt"> </p> <p> <label for="thanking">Who do we thank for referring you?</label> <input type="text" name="thanking" class="txt"> </p> <p><strong>Ready to reduce your soaring property taxes? Then check off level of assistance.</strong></p> <p> <input type="radio" value="yes" name="option"> Tool Box <input type="radio" value="no" name="option"> Self Starter Kits <input type="radio" value="no" name="option"> Predetermination Analysis <input type="radio" value="no" name="option"> Consultation <input type="radio" value="no" name="option"> Other </p> <p> Message: <textarea rows="9" name="comment" cols="30"></textarea> </p> <div id="subButton"> <input class="buttons" type="image" src="images/formSubmit.gif" tabindex="3" name="submit" value="submit" /> </div> </form> Here's the code for the script: <?php if(isset($_POST['submit'])) { $to = "[email protected]"; $subject = "Service inquiry"; $name = $_POST['name']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $owner = $_POST['owner']; $parcel = $_POST['parcel']; $phone = $_POST['phone']; $email = $_POST['email']; $thanking = $_POST['thanking']; $comment = $_POST['comment']; $option = $_POST['radio']; $body = "From: $name\n Address: $address\n City: $city\n State: $state\n Zip: $zip\n Owner: $owner\n Parcel Number: $parcel\n Phone Number: $phone\n Referral Name: $thanking\n E-Mail: $email\n Option: $option\n Message: $comment\n "; echo "Thank you! Your Wicked Awesome Service Inquiry has been submitted to $to!"; mail($to, $subject, $body, "From: $from"); } else { echo "Oops. You have reached this page in error."; } ?> I also sent this to a friend for him to test on his server. Same results..form works but no email arrives. now, someone gave me this code to try out in order to make sure it's not my server and is in fact my code: <?php $mail_test = mail("[email protected]", "Test Email", "This is a test message..."); if( $mail_test === true ) { echo "Sent email"; } else { echo "Mail failed!"; } ?> tried the page...loaded it in my browser and it worked fine...but no email hit my inbox. So, I'm not sure if it's my code or my hosting. I have a flash - to - php form for my personal site that works fine so that would have me thinking it might be my hosting. I tried moving this form and the script to a different location on the server thinking that might make a difference but it didn't. Also, again, I had a friend load it on their server as well...thinking it might be my server but the result is the same. So, I'm quite sure it's my code...but I'm just not sure where the issue is. One other thing, I looked at another tutorial with the most basic form I could find...email address and message input, button...nothing more. Same result. Not sure where to go from here. Any help or input is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/230836-email-form-problems/ Share on other sites More sharing options...
gristoi Posted March 16, 2011 Share Posted March 16, 2011 Where are you trying to send the mail function from? If it's your localhost do you have an email server installed on your machine to actually relay the email? Quote Link to comment https://forums.phpfreaks.com/topic/230836-email-form-problems/#findComment-1188393 Share on other sites More sharing options...
snottrocket Posted March 16, 2011 Author Share Posted March 16, 2011 The files live on a remote hosting server. I also, sent the files to friend who posted them on his server...same result, like I said. I'm still troubleshooting my local WAMP setup but it's kind of taking a back seat to this. Quote Link to comment https://forums.phpfreaks.com/topic/230836-email-form-problems/#findComment-1188409 Share on other sites More sharing options...
nicholasolsen Posted March 16, 2011 Share Posted March 16, 2011 Just in case you havent checked this yet: 1. Check your junkfolder... Usually where email like this ends up in todays emailingsystems. 2. See if you webhost supports emails and if you need to specify any protocols when doing so. If its a free webhost most likely they wont support it. 3. Nothing to check, just a tip: Dont try to send emails via WAMP locally.. Its a mess. There is nothing wrong with the code.. Just tested it out on my server and it worked. Quote Link to comment https://forums.phpfreaks.com/topic/230836-email-form-problems/#findComment-1188436 Share on other sites More sharing options...
snottrocket Posted March 16, 2011 Author Share Posted March 16, 2011 okay so it does work. you got an email response from the form? So it's possible that my hosting service is trashing it before it does anything? It's weird, like I mentioned before; my personal site is flash based and I have a contact form...php driven...and it works pretty good...though there are some issues, I'll address them in another thread. OKay..well, I'll send it over to my partner and see if he can get it working with a different email address just in case there's a problem there. I'll post what I find out. Thanks so much. Quote Link to comment https://forums.phpfreaks.com/topic/230836-email-form-problems/#findComment-1188454 Share on other sites More sharing options...
snottrocket Posted March 17, 2011 Author Share Posted March 17, 2011 Update: It seems to have worked...but IE8 doesn't seem to work. Partner tested on Firefox and Safari. What would be different on IE? Quote Link to comment https://forums.phpfreaks.com/topic/230836-email-form-problems/#findComment-1188539 Share on other sites More sharing options...
snottrocket Posted March 24, 2011 Author Share Posted March 24, 2011 Update: Form works great now. Thanks for all the help. Hopefully one last question: the form goes through and the email client displays the subject, body of the email but the from section lists as unknown sender or nobody. We'd like to change that to read the email address of whomever sent the info if(isset($_POST['submit']) || isset( $_POST['submit_x'] )) { $to = "[email protected]"; $subject = "subject of email!"; $name = $_POST['name']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $owner = $_POST['owner']; $parcel = $_POST['parcel']; $phone = $_POST['phone']; $email = $_POST['email']; $thanking = $_POST['thanking']; $comment = $_POST['comment']; $checkOff = $_POST['checkOff']; $body = "From: $name\n Address: $address\n City: $city\n State: $state\n Zip: $zip\n Owner: $owner\n Parcel Number: $parcel\n Phone Number: $phone\n Referral Name: $thanking\n E-Mail: $email\n Option: $checkOff\n Message: $comment\n"; echo "Thank you! Service Inquiry has been submitted to $to!"; mail($to, $subject, $body, $email); } else { echo "Oops. You have reached this page in error."; } using $email doesn't seem to work but I'm waiting to see if the server needs to update fully. Any thoughts on this? Quote Link to comment https://forums.phpfreaks.com/topic/230836-email-form-problems/#findComment-1191566 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.