Jump to content

[SOLVED] send reply to form field email address


stealthmode666

Recommended Posts

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.

 

<?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: [email protected]"; 
$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 [email protected]"; } 
}
}
?>

 

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="[email protected]" />

 

 

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

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);

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?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.