verano Posted August 11, 2009 Share Posted August 11, 2009 ok so the email that is being SENT OUT is going the wrong direction, it is going to me instead, and the RESULTS are going to the user that submitted them. <html><body><font face=Arial size=2> <form method="post" action="contactvol.php"> <table width="635" align=center bgcolor=white> <tr> <td colspan=2><strong>Request to join volunteer at our organization using this form:</strong></td></tr> <tr> <td width="222"><font color=red>*</font> Full Name:</td><td width="401"><input size=25 name="Name"></td></tr> <tr><td><font color=red>*</font> Email:</td><td><input size=25 name="Email"></td></tr> <tr> <input name="sendto" value="[email protected]" type="hidden"> <td>Animal Shelter/Rescue Name (if applicable)</td><td><p> <input size=25 name="Shelter" id="Shelter"> </p> <p> </p></td></tr> <tr> <td>Where did you find out about us?</td><td><label> <input name="WebsiteQuestion" type="text" id="WebsiteQuestion" size="25"> <br> <br> </label></td></tr> <tr> <td colspan=2>Reason you would like to be a volunteer:</td></tr> <tr><td colspan=2 align=center><textarea name="Message" rows=5 cols=35></textarea></td></tr> <tr><td colspan=2 align=center><input type=submit name="send" value="Submit"></td></tr> <tr><td colspan=2 align=center><small>A <font color=red>*</font> indicates a field is required</small></td></tr> </table> </form> </body> </html> PHP FILE <?php $to = $_REQUEST['sendto'] ; $from = $_REQUEST['Email'] ; $name = $_REQUEST['Name'] ; $headers = "From: $from"; $subject = "Domain.com: Volunteer Form"; $fields = array(); $fields{"Name"} = "Name"; $fields{"Email"} = "Email"; $fields{"Shelter"} = "Shelter"; $fields{"WebsiteQuestion"} = "WebsiteQuestion"; $fields{"Message"} = "Message"; $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: [email protected]"; $subject2 = "Thank you for contacting us"; $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.ipetrescue.com"; if($from == '') {print "You have not entered an email, please go back and try again";} else { if($name == '') {print "You have not entered a 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.domain.com/thankyou.html" );} else {print "We encountered an error sending your mail, please notify [email protected]"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/169848-php-form-to-email-simple-error-resulys-going-to-users-email-conf-email-to-me/ Share on other sites More sharing options...
MadTechie Posted August 12, 2009 Share Posted August 12, 2009 Just swap the fields around <input size=25 name="Email"></td></tr> <tr> <input name="sendto" value="[email protected]" type="hidden"> swap the Email and sendto around! <input size=25 name="sendto"></td></tr> <tr> <input name="Email" value="[email protected]" type="hidden"> Link to comment https://forums.phpfreaks.com/topic/169848-php-form-to-email-simple-error-resulys-going-to-users-email-conf-email-to-me/#findComment-896067 Share on other sites More sharing options...
verano Posted August 12, 2009 Author Share Posted August 12, 2009 Tried that and it gave me an error message, can you send the entire code, so I can try that? Just swap the fields around <input size=25 name="Email"></td></tr> <tr> <input name="sendto" value="[email protected]" type="hidden"> swap the Email and sendto around! <input size=25 name="sendto"></td></tr> <tr> <input name="Email" value="[email protected]" type="hidden"> Link to comment https://forums.phpfreaks.com/topic/169848-php-form-to-email-simple-error-resulys-going-to-users-email-conf-email-to-me/#findComment-896070 Share on other sites More sharing options...
verano Posted August 12, 2009 Author Share Posted August 12, 2009 The form itself requires the user to input an email address and that email address is used to send confirmation. The [email protected] is the email address where form results should be sent. Link to comment https://forums.phpfreaks.com/topic/169848-php-form-to-email-simple-error-resulys-going-to-users-email-conf-email-to-me/#findComment-896076 Share on other sites More sharing options...
MadTechie Posted August 12, 2009 Share Posted August 12, 2009 You shouldn't be getting any errors try something like this (so its easier to read) <?php $to = $_REQUEST['clientmail']; $from = $_REQUEST['sitemail']; $name = $_REQUEST['Name']; $headers = "From: $from"; $subject = "Domain.com: Volunteer Form"; $fields = array(); $fields{"Name"} = "Name"; $fields{"Email"} = "Email"; $fields{"Shelter"} = "Shelter"; $fields{"WebsiteQuestion"} = "WebsiteQuestion"; $fields{"Message"} = "Message"; $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $c_headers = "From: [email protected]"; $c_subject = "Thank you for contacting us"; $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.ipetrescue.com"; if($from == ''){ print "You have not entered an email, please go back and try again"; }else{ if($name == ''){ print "You have not entered a name, please go back and try again"; }else { $send = mail($from, $subject, $body, $headers); //Send to site $send2 = mail($to, $c_subject, $autoreply, $c_headers);//send to client if($send){ header( "Location: http://www.domain.com/thankyou.html" ); }else{ print "We encountered an error sending your mail, please notify [email protected]"; } } } ?> <html><body><font face=Arial size=2> <form method="post" action="contactvol.php"> <table width="635" align=center bgcolor=white> <tr> <td colspan=2><strong>Request to join volunteer at our organization using this form:</strong></td></tr> <tr> <td width="222"><font color=red>*</font> Full Name:</td><td width="401"><input size=25 name="Name"></td></tr> <tr><td><font color=red>*</font> Email:</td><td><input size=25 name="clientmail"></td></tr> <tr> <input name="sitemail" value="[email protected]" type="hidden"> <td>Animal Shelter/Rescue Name (if applicable)</td><td><p> <input size=25 name="Shelter" id="Shelter"> </p> <p> </p></td></tr> <tr> <td>Where did you find out about us?</td><td><label> <input name="WebsiteQuestion" type="text" id="WebsiteQuestion" size="25"> <br> <br> </label></td></tr> <tr> <td colspan=2>Reason you would like to be a volunteer:</td></tr> <tr><td colspan=2 align=center><textarea name="Message" rows=5 cols=35></textarea></td></tr> <tr><td colspan=2 align=center><input type=submit name="send" value="Submit"></td></tr> <tr><td colspan=2 align=center><small>A <font color=red>*</font> indicates a field is required</small></td></tr> </table> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/169848-php-form-to-email-simple-error-resulys-going-to-users-email-conf-email-to-me/#findComment-896078 Share on other sites More sharing options...
verano Posted August 12, 2009 Author Share Posted August 12, 2009 so I dont need 2 files, just this one? Link to comment https://forums.phpfreaks.com/topic/169848-php-form-to-email-simple-error-resulys-going-to-users-email-conf-email-to-me/#findComment-896090 Share on other sites More sharing options...
verano Posted August 12, 2009 Author Share Posted August 12, 2009 Just tried, still have errors, there has to be something to simply flip flop them. Link to comment https://forums.phpfreaks.com/topic/169848-php-form-to-email-simple-error-resulys-going-to-users-email-conf-email-to-me/#findComment-896092 Share on other sites More sharing options...
verano Posted August 12, 2009 Author Share Posted August 12, 2009 I see what you did, I will try this, i was stupid and thought it was one file, but the ?> gave it away, i know that much lol I will test it again Link to comment https://forums.phpfreaks.com/topic/169848-php-form-to-email-simple-error-resulys-going-to-users-email-conf-email-to-me/#findComment-896097 Share on other sites More sharing options...
verano Posted August 12, 2009 Author Share Posted August 12, 2009 It still does the same thing, but no error message and much cleaner to view, thank you for that. I have spend 2 solid days on this lol, this is sad. My fault though... but I dont get any message this time from the email I input. This is a headache. Link to comment https://forums.phpfreaks.com/topic/169848-php-form-to-email-simple-error-resulys-going-to-users-email-conf-email-to-me/#findComment-896101 Share on other sites More sharing options...
verano Posted August 12, 2009 Author Share Posted August 12, 2009 To be simply put, the email the user provides is where the form input goes, and I get the confirmation email, this is backwards, how can I correct this? Link to comment https://forums.phpfreaks.com/topic/169848-php-form-to-email-simple-error-resulys-going-to-users-email-conf-email-to-me/#findComment-896104 Share on other sites More sharing options...
verano Posted August 12, 2009 Author Share Posted August 12, 2009 Fixed. I simply reviewed the From fields in the PHP page, they needed to be defined and changed. Link to comment https://forums.phpfreaks.com/topic/169848-php-form-to-email-simple-error-resulys-going-to-users-email-conf-email-to-me/#findComment-896146 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.