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 = "admin@jeanies-poetry.com", "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 Quote 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? Quote 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\" <admin@jeanies-poetry.com>\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. admin@jeanies-poetry.com 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 admin@jeanies-poetry.com from there email address they enter. Quote 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 ("admin@jeanies-poetry.com","Contact Form Reply", $message, "FROM: \"Auto-Response\" <admin@jeanies-poetry.com>\r\n X-Mailer: PHP/" . phpversion()); But many webhosts won't let you use a FROM address that is not part of your domain. Quote 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 ("admin@jeanies-poetry.com","Contact Form Reply", $message, "FROM: \"Auto-Response\" <admin@jeanies-poetry.com>\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. Quote Link to comment https://forums.phpfreaks.com/topic/149646-contact-form-problems/#findComment-785887 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.