JeanieTallis Posted March 16, 2009 Share Posted March 16, 2009 It's a basic contact form. <?php if (isset($_POST['submit'])) { // if form has been submitted /* check they filled in what they supposed to etc: full name, email and comments */ if (!$_POST['full_name'] || !$_POST['email'] || !$_POST['comments']) { die('You did not fill in a required field.'); } if (!get_magic_quotes_gpc()) { $_POST['full_name'] = addslashes($_POST['full_name']); } if (!preg_match("/.*@.*..*/", $_POST['email']) || preg_match("/(<|>)/", $_POST['email'])) { die('Invalid e-mail address.'); } $_POST['full_name'] = strip_tags($_POST['full_name']); $_POST['comments'] = strip_tags($_POST['comments']); if (!get_magic_quotes_gpc()) { $_POST['full_name'] = addslashes($_POST['full_name']); $_POST['email'] = addslashes($_POST['email']); $_POST['comments'] = addslashes($_POST['comments']); } $message = "Comments from Contact form\n\n Name: $_POST[full_name] \n Email: $_POST[email] \n Comments: $_POST[comments] \n "; /* Mail To, subject, message */ $my_email = "[email protected]", "Contact Form Reply", $message, "From:" \$_POST[full_name]\ $_POST[email]. /* Mail From */ "X-Mailer: PHP/" . phpversion()); echo("Your email has been sent, you will get a reply shortly."); exit; } ?> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label> <div align="center">Full Name: <input name="full_name" type="text" id="full_name"> </div> </label> <p align="center"> <label>Your Email: <input name="email" type="text" id="email"> </label> </p> <p align="center"> <label>Comments<br> <textarea name="comments" cols="80" rows="20" id="comments"></textarea> </label> </p> <p align="center"> <label> <input name="submit" type="submit" id="submit" value="Send"> </label> </p> </form> The mail to and from, are wrong. Can you correct this. Thanks Link to comment https://forums.phpfreaks.com/topic/149646-contact-form-problems/ Share on other sites More sharing options...
Maq Posted March 16, 2009 Share Posted March 16, 2009 What's wrong and what happens? Link to comment https://forums.phpfreaks.com/topic/149646-contact-form-problems/#findComment-785799 Share on other sites More sharing options...
JeanieTallis Posted March 16, 2009 Author Share Posted March 16, 2009 What's wrong and what happens? Well, everythings correct, its just this bit is that we focus at (origionally what i had is below) mail($_POST['email'] , "Contact Form Reply", $message, "From: \"Auto-Response\" <[email protected]>\r\n". "X-Mailer: PHP/" . phpversion()); echo("Your email has been sent, you will get a reply shortly."); This emails the person using the contact form, coming from the person I want it to go to. [email protected] is who I want the form to go to. $_POST['email'] is, the email the person on the contact form enters in (there email) and thats who the email comes from. I want to know, how to change that bit to make the form go to [email protected] from there email address they enter. Link to comment https://forums.phpfreaks.com/topic/149646-contact-form-problems/#findComment-785816 Share on other sites More sharing options...
revraz Posted March 16, 2009 Share Posted March 16, 2009 The first parameter for MAIL () is the TO field mail ("[email protected]","Contact Form Reply", $message, "FROM: \"Auto-Response\" <[email protected]>\r\n X-Mailer: PHP/" . phpversion()); But many webhosts won't let you use a FROM address that is not part of your domain. Link to comment https://forums.phpfreaks.com/topic/149646-contact-form-problems/#findComment-785821 Share on other sites More sharing options...
JeanieTallis Posted March 16, 2009 Author Share Posted March 16, 2009 The first parameter for MAIL () is the TO field mail ("[email protected]","Contact Form Reply", $message, "FROM: \"Auto-Response\" <[email protected]>\r\n X-Mailer: PHP/" . phpversion()); But many webhosts won't let you use a FROM address that is not part of your domain. Thank you for the help can you check out the last post on my other thread http://www.phpfreaks.com/forums/index.php?topic=243205 its a download for my .rar login form, i have alot of errors within it. Thanks. Link to comment https://forums.phpfreaks.com/topic/149646-contact-form-problems/#findComment-785887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.