gibson Posted May 26, 2006 Share Posted May 26, 2006 Hello, I am very new to PHP, in fact I really dont have a clue about the coding but I know I need to use it. I am building a website using Dreamweaver and want to have a form so a customer can contact me. The following is the HTML for the form I am using to play about with to try and get it working:[code]<form name="form1" method="post" action="submit.php"> <label>Name <input name="name" type="text" id="name"> </label> <p> <label>Email <input name="email" type="text" id="email"> </label> </p> <p> <label>Message:<br> <textarea name="message" cols="50" rows="4" id="message"></textarea> </label> </p> <p> <center><label> <input type="submit" name="Submit" value="Submit"> </label> <label> <input type="reset" name="Submit2" value="Reset"> </label> </center> </p></form>[/code]I found some PHP code on a website which allows me to send what is inputted in the form to my email address and this is it below:[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><p> <?php$to="email removed for privacy reasons";$subject="Mail from your website";$from="FROM: ".$_POST['name']." <".$_POST['email'].">\n";$message="This message is from the website.Name: ".$_POST['name']."Email: ".$_POST['email']."Message: ".$_POST['message'];//Now to actually send itmail($to, $subject, $message, $from);?> </p><p>Thank you for contacting us. We will get back to you within two business days.</p></body></html>[/code]This code is working fine but it only sends me an email with what was inputted, I would also like the customer to be sent an email to tell them that I have received their query and will get back to them within two business days. Would you be able to tell me what code I would have to use for this? It would be going to the email that they have inputted and will be from my email with a subject of something like 'Thank you for contacting us' and then the message would be something like 'Thank you for contacting us. We will get back to you within two business days'Thanks for any help you can give me Quote Link to comment https://forums.phpfreaks.com/topic/10537-sending-emails-from-forms-to-both-me-and-the-person-inputting-information/ Share on other sites More sharing options...
poirot Posted May 26, 2006 Share Posted May 26, 2006 Huh, just send another email right after it:Something like this:[code]mail($to, $subject, $message, $from);$msg2 = 'Your Thank you message';$email = 'YourEmail@example.com';$name = 'Your Name';mail($_POST['email'], 'Thank you', $msg2, 'From: ' . $name . '<' . $email . '>');[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10537-sending-emails-from-forms-to-both-me-and-the-person-inputting-information/#findComment-39317 Share on other sites More sharing options...
gibson Posted May 26, 2006 Author Share Posted May 26, 2006 Thank you, Ill try this out and Ill get back to you about whether it has worked. I tried something similar before but it was coming up an error but maybe I was just making a mistake in the syntax or something, so Ill try this code and hopefully itll work for me. Quote Link to comment https://forums.phpfreaks.com/topic/10537-sending-emails-from-forms-to-both-me-and-the-person-inputting-information/#findComment-39323 Share on other sites More sharing options...
gibson Posted May 27, 2006 Author Share Posted May 27, 2006 Well this hasnt worked. I didnt receive any emails at all this time, not even the email with the information from the form which was the part that was working. It loads the page whenever I click the submit button without any problems so it looks as if it has worked, but I never got any emails. I have played about with the code and still it hasnt worked. Have you got any ideas of what could be wrong with it? Quote Link to comment https://forums.phpfreaks.com/topic/10537-sending-emails-from-forms-to-both-me-and-the-person-inputting-information/#findComment-39417 Share on other sites More sharing options...
Randy Posted May 27, 2006 Share Posted May 27, 2006 [code]<HTML> <head> <title>E-mail sent to your Inbox</title> </head> <body> <?php $to = "email removed for privacy reasons"; $subject = "Mail from your website"; $from = "FROM: ".$_POST['name']." <".$_POST['email'].">\n"; $message = wordwrap("This message is from the website.\n\nName: ".$_POST['name']."\nEmail: ".$_POST['email']."\nMessage: ".$_POST['message'], 70); mail($to, $subject, $message, $from); $to = $_POST['email']; $subject = "Thankyou!"; $from = "FROM: Site Admin <bob@hotmail.com>"; $message = wordwrap("Thankyou ".$_POST['name'].", blah blah blah", 70); mail($to, $subject, $message, $from); ?> <p>Thank you for contacting us. Please check your Inbox.</p> </body></HTML>[/code]Try this... Quote Link to comment https://forums.phpfreaks.com/topic/10537-sending-emails-from-forms-to-both-me-and-the-person-inputting-information/#findComment-39422 Share on other sites More sharing options...
gibson Posted May 27, 2006 Author Share Posted May 27, 2006 This now comes up when you click the submit button:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected T_VARIABLE in /web/sites/320/gerrygibson/www.gerrygibson.f2s.com/submit2.php on line 15[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/10537-sending-emails-from-forms-to-both-me-and-the-person-inputting-information/#findComment-39423 Share on other sites More sharing options...
Randy Posted May 27, 2006 Share Posted May 27, 2006 Oh yeah, i had missed out a semicolon, i have edited the script so it should work now... Quote Link to comment https://forums.phpfreaks.com/topic/10537-sending-emails-from-forms-to-both-me-and-the-person-inputting-information/#findComment-39425 Share on other sites More sharing options...
gibson Posted May 27, 2006 Author Share Posted May 27, 2006 ok, thanks very much, Ill try it out nowNo error came up this time, now Ill just have to wait and see if the emails arrive. Ill reply later to tell you if its worked or not. Thanks again for your help Quote Link to comment https://forums.phpfreaks.com/topic/10537-sending-emails-from-forms-to-both-me-and-the-person-inputting-information/#findComment-39428 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.