Hi,
I just read the tutorial about making a PHP email form and it was great. There’s just a couple of things I’d like to know how to change…
First off, when the user hits submit, I don’t want it to ‘echo’ a message, I’d like it to take them to another web page. I made a simpler form previously that contained this line “header(‘Location:thanks.html’);” but when I try to include this in the new script, it doesn’t work.
Secondly, when I receive an email using this form, it includes all of the details in the body, but it doesn’t populate the ‘From’ box with the user’s email address. The previous script contained this line: “mail(‘info@olicorse.com’, $subject, $enquiry, ‘From:’ . $name . ’ <’ . $email . ‘>’);” but again, when I try to replace the line in this script, it displays an error.
Here is the script I am using (I have made some minor alterations, but they all work ok). Can someone please tell me where to make the necessary changes so I can redirect users to another HTML page and also how to populate the email field in my client?
Thanks in advance!
<?php
if(isset($_POST[‘submit’])) {
$to = "info@olicorse.com";
$subject = “Website Query”;
$name_field = $_POST[‘name’];
$phone_field = $_POST[‘phone’];
$biz_field = $_POST[‘business’];
$email_field = $_POST[‘email’];
$message = $_POST[‘message’];
$dropdown = $_POST[‘drop_down’];
foreach($_POST[‘check’] as $value) {
$check_msg .= "
$value
";
}
$body = "Name: $name_field
E-Mail: $email_field
Phone: $phone_field
Business: $biz_field
Areas of Interest:
$check_msg
Message:
$message
Heard from: $dropdown";
echo “Data has been submitted to $to!”;
mail($to, $subject, $body);
} else {
echo “blarg!”;
}
?>