CSpoon Posted September 22, 2006 Share Posted September 22, 2006 Hi again,Well thanks so much the help generous help received so far, what wonderful people and privilege!My email form is almost working exactly how I want it to, but one issue still eludes this newbie, though I've experimented with it.The email address the message is sent from is that of the server (where it originates from), not that of the website user, as entered in the form. It would be great if it went to the user when "reply" is hit. Is this possible?Here is the script:[color=blue]<?php if ($_SERVER['REQUEST_METHOD'] != 'POST'){ $me = $_SERVER['PHP_SELF'];?> <form name="form1" method="post" action="<?php echo $me;?>"> <table border="0" cellspacing="0" cellpadding="2"> <tr> <td><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif">Name</font></td> <td><input type="text" name="Name"></td> </tr> <tr> <td><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif">Email</font></td> <td><input type="text" name="email"></td> </tr> <tr> <td valign="top"><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif">Mailing Address </font></td> <td><textarea name="MsgBody" class="textarea"></textarea></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Send"></td> </tr> </table> </form><?php } else { error_reporting(0); // $recipient = '[email protected]'; $subject = 'Catalogue request'; $from = stripslashes($_POST['Name']); $msg = "The following website user has requested a catalogue:\n\n Name: $from\n\n Email: $email\n\n Address: ".stripslashes($_POST['MsgBody']); if (mail($recipient, $subject, $msg)) echo nl2br("<font color=#339900 size= 2 face='Verdana, Arial, Helvetica, sans-serif'><strong><br>Thanks for your request!</strong></font><font color=#339900 size= 2 face='Verdana, Arial, Helvetica, sans-serif'>A catalogue will be sent to: <br> $msg "); else echo "Message failed to send, please try again later or contact our office.";}?>[/color] Link to comment https://forums.phpfreaks.com/topic/21688-email-form-problem/ Share on other sites More sharing options...
ronverdonk Posted September 22, 2006 Share Posted September 22, 2006 This will do it. Add the sender email address ($user) in the $header var and add that to your mail() command.[code]$header = "From: $user\n";if (mail($recipient, $subject, $msg, $header))[/code]Ronald 8) Link to comment https://forums.phpfreaks.com/topic/21688-email-form-problem/#findComment-96831 Share on other sites More sharing options...
CSpoon Posted September 22, 2006 Author Share Posted September 22, 2006 [quote author=ronverdonk link=topic=109093.msg439513#msg439513 date=1158943457]This will do it. Add the sender email address ($user) in the $header var and add that to your mail() command.[code]$header = "From: $user\n";if (mail($recipient, $subject, $msg, $header))[/code]Ronald 8)[/quote]Hi Ronald... thanks for replying. I figured-out that "$user\n" in my case would be "$email\n" however it did not work. Nothing different happened.When I tried using:[color=blue]$mailheader = "From: $senderemail\n";$mailheader .= "Reply-To: $senderemail\n\n";[/color]The email address came-up blank, and a reply revealed a syntax error. Link to comment https://forums.phpfreaks.com/topic/21688-email-form-problem/#findComment-96913 Share on other sites More sharing options...
AdRock Posted September 22, 2006 Share Posted September 22, 2006 here is a tutorial/code snippet whcih might help you[url=http://www.ibdhost.com/contact/]http://www.ibdhost.com/contact/[/url] Link to comment https://forums.phpfreaks.com/topic/21688-email-form-problem/#findComment-96959 Share on other sites More sharing options...
CSpoon Posted September 22, 2006 Author Share Posted September 22, 2006 [quote author=AdRock link=topic=109093.msg439642#msg439642 date=1158957993]here is a tutorial/code snippet whcih might help you[url=http://www.ibdhost.com/contact/]http://www.ibdhost.com/contact/[/url][/quote]Thanks for trying.Have not found a solution here.My code uses PHP_SELF. Link to comment https://forums.phpfreaks.com/topic/21688-email-form-problem/#findComment-96998 Share on other sites More sharing options...
CSpoon Posted September 22, 2006 Author Share Posted September 22, 2006 [quote author=CSpoon link=topic=109093.msg439682#msg439682 date=1158963559][quote author=AdRock link=topic=109093.msg439642#msg439642 date=1158957993]here is a tutorial/code snippet whcih might help you[url=http://www.ibdhost.com/contact/]http://www.ibdhost.com/contact/[/url][/quote]Thanks for trying.Have not found a solution here.My code uses PHP_SELF.[/quote][color=green]Hello Everyone, the problem is solved, thanks to the most complete and best-written tutorial on the subject that I have found on the net: http://www.weberdev.com/ViewArticle.php3?ArticleID=10 Thanks to everyone for their efforts!! [/color] Link to comment https://forums.phpfreaks.com/topic/21688-email-form-problem/#findComment-97006 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.