Hi there. Believe me, I have tried everything, searched everywhere, but this PHP newbie can't get this to work:
1) Mail with a "Thanks for application" subject must go to user (field_4).
2) Mail to vendor and management with "Application received" subject line must go to manager in field_5, and two other admin addresses (which I have as foo1 and foo2)
Below is the (abridged) basic code I have been working from; have seperated foo1 and foo2 with comma. I imagine that $_POST['field_4'] would come in before that.
Anyone care to tackle this one? Much appreciated in advance! (and, any advice on having the "From:" field showing something other than the "Nobody" my server appends to mails from the form would also be welcomed!) Cheers!
You know what? I worked it all out. The (abridged) code is below. Enjoy. May still fiddle with it, but it is all working at this time.
Still to solve a nagging issue with Japanese characters turning up as gobbledygook on Outlook Express/Entourage (have set html page as utf-8, but still no go). Ho hum.
/////////sending to applicant//////
$headers2 = "From: xyz@zyz.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for your application for the test. You entered the information below. If you have any more questions, please consult our website at xyz@zyz.com.
if($email == '') {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";}
Hi there. Believe me, I have tried everything, searched everywhere, but this PHP newbie can't get this to work:
1) Mail with a "Thanks for application" subject must go to user (field_4).
2) Mail to vendor and management with "Application received" subject line must go to manager in field_5, and two other admin addresses (which I have as foo1 and foo2)
Below is the (abridged) basic code I have been working from; have seperated foo1 and foo2 with comma. I imagine that $_POST['field_4'] would come in before that.
Anyone care to tackle this one? Much appreciated in advance! (and, any advice on having the "From:" field showing something other than the "Nobody" my server appends to mails from the form would also be welcomed!) Cheers!
<?php
$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
mail("foo1@foo.com,foo2@foo.com","Application for the XYZ test","Form data:
Location: " . $_POST['field_1'] . "
Name: " . $_POST['field_2'] . "
Employee Code: " . $_POST['field_3'] . "
Email: " . $_POST['field_4'] . "
Manager Email: " . $_POST['field_5'] . "
Division name: " . $_POST['field_6'] . "
Phone: " . $_POST['field_7'] . "
powered by phpFormGenerator.
");
include("confirm.html");
?>
You know what? I worked it all out. The (abridged) code is below. Enjoy. May still fiddle with it, but it is all working at this time.
Still to solve a nagging issue with Japanese characters turning up as gobbledygook on Outlook Express/Entourage (have set html page as utf-8, but still no go). Ho hum.
Cheers.
--
<?php
/////////form values//////
$location = $_POST["location"];
$name = $_POST["name"];
$code = $_POST["code"];
$email = $_POST["email"];
$managermail = $_POST["managermail"];
$division = $_POST["division"];
$phone = $_POST["phone"];
/////////sending to admin//////
$to = $managermail;
$toadmin = 'address1@xyz.com,address2@xyz.com' . ', ';
$from = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$headers = "From: $from";
$subject = "Application Form Data";
$autoreply1 = "The following information was sent via the application form by $name:
Location: ".$location."
Name: ".$name."
Employee code: ".$code."
Email address: ".$email."
Manager email: ".$managermail."
Division: ".$division."
Phone: ".$phone."
End of information."
;
/////////sending to applicant//////
$headers2 = "From: xyz@zyz.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for your application for the test. You entered the information below. If you have any more questions, please consult our website at xyz@zyz.com.
Location: ".$location."
Name: ".$name."
Employee code: ".$code."
Email address: ".$email."
Manager email: ".$managermail."
Division: ".$division."
Phone: ".$phone."
End of information."
;
if($email == '') {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, $autoreply1, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
$send3 = mail($toadmin, $subject, $autoreply1, $headers);
if($send)
{header( "Location: http://www.foo.com" );}
else
{print "We encountered an error sending your mail, please notify xyz@zyz.com"; }
}
}
?>