stealthmode666 Posted December 11, 2008 Share Posted December 11, 2008 I need help with my script. newbbie I have it processing a large form which all works. On submit it sends the data to a .php file which processes it and sends this to an email address and displays a thank-you page. I have pieced together the script from bits and pieces which I mostly understand, but I am having problems with the part I want to send an auto-reply too of the user who fills in their email address on the form page. The auto-reply is coming to me along with the form data. I have tried looking for tutorials on this but as yet not found one. If I need to post the scipt how do i do this? As in do I use tags to put it in or do I just post it in the message box? Thanks if anyone can help me on this. Quote Link to comment Share on other sites More sharing options...
trq Posted December 11, 2008 Share Posted December 11, 2008 If I need to post the scipt how do i do this? As in do I use tags to put it in or do I just post it in the message box? Post your code in the message box between tags. Quote Link to comment Share on other sites More sharing options...
stealthmode666 Posted December 12, 2008 Author Share Posted December 12, 2008 <?php $to = ( isset ($_REQUEST['sendto']) ? $_REQUEST['sendto'] : "default 'to' email goes here" ); $from = ( isset ($_REQUEST['Email']) ? $_REQUEST['sendto'] : "default 'from' email goes here" ) ; $name = ( isset ($_REQUEST['Member_Name']) ? $_REQUEST['Member_Name'] : "Default member name goes here" ) ; $headers = "From: $from"; $subject = "Members .......com"; $fields = array(); $fields{"Member_Name"} = "Members Name"; $fields{"telephone"} = "Members Contact Phone Number"; $fields{"Email"} = "Members Email Address"; plus about another 80 odd fields $body = "You have .........from.. .com:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: me@somewhere.com"; $subject2 = "Thank-you for filling in....."; $autoreply = "Somebody from ........ Thank-you"; if($from == '') {print "You have not entered an Email Address, please go back and try again";} else { if($name == '') {print "You have not entered a First Name, please go back and try again";} else { $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send){header( "Location: http://www.r.....com/r..../thankyou.html" );} else {print "We encountered an error sending your mail, please notify webmaster@someone.com"; } } } ?> I have a hidden field in the form for the email to be sent to on submit. I have used server-side .js validation to check the form so it can only can be submitted when it's correct. <form method="post" action="http://www.r....com/r.../sform.php"> <input name="sendto" type="hidden" id="sendto" value="me@someone.com" /> Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 so whats the problem? the second email isn't sending or what? Quote Link to comment Share on other sites More sharing options...
stealthmode666 Posted December 12, 2008 Author Share Posted December 12, 2008 Yes, the auto-reply email is not going to the form field email address. I get the email address in my email of the user, but they don't get an email to say thank-you there details of the form have been received and someone will get back to them. It works when at my end, but when I change the email address of where to send the form that part works, but then the users email address doesn't get an auto-reply message Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 change it to this just to see if it works; $send = mail($to, $subject, $body, $headers); $send2 = mail($to, $subject2, $autoreply, $headers2); Quote Link to comment Share on other sites More sharing options...
stealthmode666 Posted December 12, 2008 Author Share Posted December 12, 2008 thanks but no luck, it has still sent the auto-reply back to me at the same email address as I have for the form to come to Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 Change $from = ( isset ($_REQUEST['Email']) ? $_REQUEST['sendto'] : "default 'from' email goes here" ) ; to this $from = ( isset ($_REQUEST['Email']) ? $_REQUEST['Email'] : "default 'from' email goes here" ) ; and change this $send = mail($to, $subject, $body, $headers); $send2 = mail($to, $subject2, $autoreply, $headers2); back to this $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); Quote Link to comment Share on other sites More sharing options...
stealthmode666 Posted December 12, 2008 Author Share Posted December 12, 2008 I tried that earlier today and ended up with a page of notice:undefined index....line 188 and a warning about... actually i'll do it again and post the exact errors I get with the above Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 let me know what you get Quote Link to comment Share on other sites More sharing options...
stealthmode666 Posted December 12, 2008 Author Share Posted December 12, 2008 Okay, looking over my earlier notes from today, I spelt it email instead of Email. No wonder I got a page of notices and a warning. I checked the headers of each email to see where they came from and both show properly now. I have all this running back to me via e-mail forwarding using different email addresses till I know it works. The to: field shows the form data has come to me and the from: field shows the users email address from the form which shows the message I have in the auto-reply. Thank-you so much for this. Next thing I need is how to make the processed form in the email display better other than a list of rows which is about 100 in length. Is there a way I can send the data in a better way? I am still learning MySQL and how to store the form details so at the moment MySQL is out. can I somehow have the email on submit process the details of the form into something the same as the form? should I post this as a seperate question and mark this post as solved? Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 Yea that would be good. start fresh 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.