Jump to content

php contact form auto-responder


jasonmilburn

Recommended Posts

I have built a form which uses PHP to email the information at http://www.rogerworthington.com . It works fine, but hte client now wants hte form to also email to the person who filled it out. I tried a couple things and couldn't get it to work. Any help would be appreciated! Here is the PHP code that handles the form:

 

<?php

if(isset($_POST['Submit'])) {

$to = "[email protected]";

$subject = "MESOTHELIOMA Request For More Information";

 

foreach($_POST['check'] as $value) {

$check_msg .= "Checked: $value\n";

}

 

$type = $_POST['type'];

$ifother = $_POST['ifother'];

 

$name_field = $_POST['name'];

$phone = $_POST['phone'];

$confirmphone = $_POST['phone2'];

$email_field = $_POST['email'];

$confirmemail = $_POST['email2'];

$address_field = $_POST['address'];

$city_field = $_POST['city'];

$state_field = $_POST['state'];

$zip_field = $_POST['zip'];

$time = $_POST['time'];

$claim = $_POST['claim'];

$exposed = $_POST['exposed'];

 

 

 

$body = "Diagnosed with Mesothelioma? $check_msg\n

Type of Mesothelioma: $type\n

If Other: $ifother\n \n

Name: $name_field\n

Phone: $phone\n

COnfirm Phone: $confirmphone\n

E-Mail: $email_field\n

Confirm E-Mail: $confirmemail\n

Address: $address_field\n

City: $city_field\n

State: $state_field\n

Zip Code: $zip_field\n

Best Time To Call: $time\n

Claim is For: $claim\n

I was exposed to Asbestos: $exposed\n

";

 

echo "Thank you for contacting us.";

mail($to, $subject, $body);

} else {

echo "Error!";

}

?>

Link to comment
https://forums.phpfreaks.com/topic/67831-php-contact-form-auto-responder/
Share on other sites

ok ill try that.

 

I also thought I could just stick the email result right in the to line like this:

 

$to = "[email protected], $email_field";

 

So it would send the form to both emails. Or can I just stick a line like this right under the existing mail line:

 

mail($email_field, $subject, $body);

 

or does the mail function have to have a $to value in order to understand it is an email address?

 

This will not work:

$to = "[email protected], $email_field"; 

 

 

change to:

 

$to = "[email protected]"($email_field); 

 

 

 

 

i guess this will not work

 

$to = "[email protected]"($email_field); 

try

$to = "[email protected],". $email_field; 

 

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.