# PHP mail form tutorial trouble

**URL:** <https://forum.kirupa.com/t/php-mail-form-tutorial-trouble/69492>\
**Category:** programming\
**Created:** [November 4, 2004, 8:00pm UTC](https://forum.kirupa.com/t/php-mail-form-tutorial-trouble/69492 "2004-11-04T20:00:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![exorxist](https://avatars.discourse-cdn.com/v4/letter/e/f4b2a3/32.png) [@exorxist](https://forum.kirupa.com/u/exorxist)\
**Post date:** [November 4, 2004, 8:00pm UTC](https://forum.kirupa.com/t/php-mail-form-tutorial-trouble/69492/1 "2004-11-04T20:00:12Z")

</div>

I’ve been working with the php mail form tutorial, and everything is working great except for one thing. If I chose to not redirect, it works, but if I want to redirect the browser to another page, it gives me an error. This is the code

\<?PHP  
$to = “[adress@wherever.com](mailto:adress@wherever.com)”;

$subject = “Test Form Regus”;

$headers = “From: Performance Bridge”;

$forward = 0; \<- when I change this to 1, it gives me an error

$location = “[http://www.wherever.com](http://www.wherever.com)”;

$date = date (“l, F jS, Y”);  
$time = date (“h:i A”);  
$msg = "Below is the result of your feedback form. It was submitted on $date at $time.

“;  
if ($\_SERVER[‘REQUEST\_METHOD’] == “POST”) {  
foreach ($\_POST as $key =\> $value) {  
$msg .= ucfirst ($key) .” : ". $value . "  
“;  
}  
}  
else {  
foreach ($\_GET as $key =\> $value) {  
$msg .= ucfirst ($key) .” : ". $value . "  
";  
}  
}  
mail($to, $subject, $msg, $headers);  
if ($forward == 1) {  
header (“Location:$location”);  
}  
else {  
echo “Thank you for submitting our form. We will get back to you as soon as possible.”;  
}

?\>

Any ideas why

($forward == 1) {  
header (“Location:$location”);  
}

will not let me redirect? Thanks in advance!
