bigrossco Posted July 26, 2007 Share Posted July 26, 2007 I have the contact form below, but what I am wanting to do is make the input email address by the user, appear as the FROM address in the emails that are sent to the specified address: <form method="post" action="<?php echo($PHP_SELF) ?>"> <fieldset> <legend>Contact Form</legend> <p><label>Name:</label> <input name="name" type="text" id="name" size="40"> </p> <p><label>Email:</label> <input name="email" type="text" id="email" size="40"> </p> <p> <label>Message:<br /> </label><textarea name="comments" cols="50" rows="10" id="comments"></textarea> </p> <p><input type="submit" name="submit" id="submit" value="Send Message"></p> </fieldset> </form> <?php # Add your email address $to = 'test@test.com'; # Add a default subject $subject = 'New Message Recived'; $name = $_REQUEST['name']; $email = $_REQUEST['email']; $comments = $_REQUEST['comments']; $submit = $_REQUEST['submit']; $body = "$name $email $comments"; if(isset($submit)) { mail($to, $subject, $body);} ?></ Quote Link to comment Share on other sites More sharing options...
per1os Posted July 26, 2007 Share Posted July 26, 2007 www.php.net/mail Look into mail headers. Quote Link to comment Share on other sites More sharing options...
dewey_witt Posted July 26, 2007 Share Posted July 26, 2007 $headers = "From: $email\n"; and this will alow for a auto fill after pushing "reply". $headers .= "Reply-To: $email\n\n"; This is the way you formulate a mail header. Then when you send the mail Do it in this order mail($to, $subject, $body, $headers); So what we end up with is this <? # Add your email address $name = $_REQUEST['name']; $email = $_REQUEST['email']; $comments = $_REQUEST['comments']; $submit = $_REQUEST['submit']; $to = 'test@test.com'; # Add a default subject $subject = 'New Message Recived'; $headers = "From: $email\n"; $headers .= "Reply-To: $email\n\n"; $body = "$name $email $comments"; if(isset($submit)) { mail($to, $subject, $body, $headers);} ?> Quote Link to comment Share on other sites More sharing options...
bigrossco Posted July 26, 2007 Author Share Posted July 26, 2007 thank you very much, that has done the trick Ross Quote Link to comment 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.