fcuk89 Posted August 16, 2011 Share Posted August 16, 2011 Hi, I'm trying to create a contact us page - with name, email and message required. When I tried the contact us form, the message got through, but the name of recipient and the email of recipient does not appear when I receive the message on my email. With that, I can't just hit reply as there is no email address filled out already. This is my first time building contact form, so any help would much be appreciated. HTML <table width="89%" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="58" valign="top"><img src="image/contact/feed_form.png" width="109" height="42"></td> </tr> <tr> <td height="254" valign="top"> <form name="form1" method="post" action="mail.php" onSubmit="return isValidEmail(this)"> <table height="78%"> <tr> <td width="310" height="40" align="left" valign="top"> <input type="text" name="name" style="width: 290px; height: 30px; padding: 2px; border: 1px solid #c0c0c0;" placeholder="Your name" > </td> </tr> <tr> <td height="39" valign="top" align="left"> <input name="email" type="text" style="width: 290px; height: 30px; padding: 2px; border: 1px solid #c0c0c0;" placeholder="Your email" /></td> </tr> <tr> <td height="110" valign="top"><textarea name="message" style="width: 290px; height: 100px; padding: 2px; border: 1px solid #c0c0c0;"></textarea></td> </tr> <tr> <td height="52" align="right" valign="top"><input type="submit" style="width: 100px; height: 50px;" value="Send"/></td> </tr> </table> PHP <?php header("Refresh: 3;url=contact.html"); ?> <?php $to = "***********"; $name = $_REQUEST['name']; $subject = "Feedback from customer ".$name."!"; $email = $_REQUEST['mail'] ; $message = $_REQUEST['message'] ; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully. <br/>You will be redirected to the contact us page in 3 seconds"; } else {print "We encountered an error sending your mail"; } ?> Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/244880-contact-form-help/ Share on other sites More sharing options...
phpSensei Posted August 16, 2011 Share Posted August 16, 2011 $_REQUEST can hold many levels of data, including cookies sessions post get. I would chose $_POST explicitly here,because its safer to know where your data is coming from, Mail can be a cookie from the user for all we know, thats not where your problems lie here though. Tname of the Email field isn't Mail its Email change $_POST['mail'] to $_POST['email'] <input name="email" type="text" style="width: 290px; height: 30px; padding: 2px; border: 1px solid #c0c0c0;" placeholder="Your email" /> Quote Link to comment https://forums.phpfreaks.com/topic/244880-contact-form-help/#findComment-1257968 Share on other sites More sharing options...
chintansshah Posted August 16, 2011 Share Posted August 16, 2011 are checking mail on your local pc or on web server? Quote Link to comment https://forums.phpfreaks.com/topic/244880-contact-form-help/#findComment-1257991 Share on other sites More sharing options...
phpSensei Posted August 16, 2011 Share Posted August 16, 2011 are checking mail on your local pc or on web server? No, he isn't using the proper $_POST var names, has nothing to do with server until he fixes that... Quote Link to comment https://forums.phpfreaks.com/topic/244880-contact-form-help/#findComment-1257993 Share on other sites More sharing options...
chintansshah Posted August 16, 2011 Share Posted August 16, 2011 you are right phpSensei, it's very true to change code for $_POST variables and values. change $_POST['mail'] to $_POST['email'] Quote Link to comment https://forums.phpfreaks.com/topic/244880-contact-form-help/#findComment-1257995 Share on other sites More sharing options...
fcuk89 Posted August 17, 2011 Author Share Posted August 17, 2011 Thank you all for the reply. I have managed to resolve the problem. Thanks so much. Quote Link to comment https://forums.phpfreaks.com/topic/244880-contact-form-help/#findComment-1258641 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.