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 = '[email protected]'; # 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);} ?></ Link to comment https://forums.phpfreaks.com/topic/61884-solved-contact-form-help/ 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. Link to comment https://forums.phpfreaks.com/topic/61884-solved-contact-form-help/#findComment-308095 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 = '[email protected]'; # 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);} ?> Link to comment https://forums.phpfreaks.com/topic/61884-solved-contact-form-help/#findComment-308110 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 Link to comment https://forums.phpfreaks.com/topic/61884-solved-contact-form-help/#findComment-308119 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.