# Email Form problems

**URL:** <https://forum.kirupa.com/t/email-form-problems/298475>\
**Category:** programming\
**Created:** [October 19, 2009, 8:50pm UTC](https://forum.kirupa.com/t/email-form-problems/298475 "2009-10-19T20:50:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![olicorse](https://avatars.discourse-cdn.com/v4/letter/o/45deac/32.png) [@olicorse](https://forum.kirupa.com/u/olicorse)\
**Post date:** [October 19, 2009, 8:50pm UTC](https://forum.kirupa.com/t/email-form-problems/298475/1 "2009-10-19T20:50:22Z")

</div>

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!”;

}  
?\>
