Hello all,
I am here begging for help with this chunk of code.
I have a form that was created with phpformgenerator,
and I have a need to send email to a specific address
based on a selection made. So, I have this as the email
processing script...
<?php
if($field_5=="tom") {
mail("user1@aca.local","phpFormGenerator - Form submission","Form data:
First Name: " . $_POST['field_1'] . "
Last Name: " . $_POST['field_2'] . "
Phone: " . $_POST['field_3'] . "
Email: " . $_POST['field_4'] . "
Select a Doctor: " . $_POST['field_5'] . "
Ask the Doctor: " . $_POST['field_6'] . "
powered by phpFormGenerator.
");
} else if ($field_5=="bob") {
mail("user2@aca.local","phpFormGenerator - Form submission","Form data:
First Name: " . $_POST['field_1'] . "
Last Name: " . $_POST['field_2'] . "
Phone: " . $_POST['field_3'] . "
Email: " . $_POST['field_4'] . "
Select a Doctor: " . $_POST['field_5'] . "
Ask the Doctor: " . $_POST['field_6'] . "
powered by phpFormGenerator.
");
} else {
mail("user3@aca.local","phpFormGenerator - Form submission","Form data:
First Name: " . $_POST['field_1'] . "
Last Name: " . $_POST['field_2'] . "
Phone: " . $_POST['field_3'] . "
Email: " . $_POST['field_4'] . "
Select a Doctor: " . $_POST['field_5'] . "
Ask the Doctor: " . $_POST['field_6'] . "
powered by phpFormGenerator.
");
}
include("confirm.html");
?>
When the form is accessed, and the selected user is either tom or bob,
it writes two errors in my log file ....
PHP Notice: Undefined variable: field_5 in /var/www/html/processor2.php on line 3
PHP Notice: Undefined variable: field_5 in /var/www/html/processor2.php on line 19
It will still send email, but not to the correct address. It uses the last
email "user3@aca.local" . When in fact, I would like it to send to the
correct email address based on the selection from the drop down box.
I am hoping that one of the brilliant PHP experts can look at this and
see what is wrong. I have not included the form.html, it is much longer.
If requested, I will certainly post it.
Thanks in advance for all of your help,
Mike