PDA

View Full Version : Spot the problem!


APC
09-14-2008, 11:17 AM
Hey all, I'm having a little bit of a problem trying to spot the error in the following piece of code:


<?php

if(isset($_POST['name'])) {

$name = $_POST['name'] . "\n";
$email = $_POST['email'] . "\n";
$subject = $_POST['subject'] . "\n";
$messageorig = $_POST['message'] . "\n";

$message = "Name: $name " . "\n";
$message .= "Email: $email " . "\n";
$message .= "Message: $messageorig " . "\n";

if(mail("emailaddress@hotmail.com", $subject, $message, "From: Contact Form")) {
header("Location: thankyou.html");
} else {
echo "Mail sending failed";
}

}
?>


The page thankyou.html exists and works fine. I've been using this page for about 4 or 5 months now and it's been working fine, however when I tested it yesterday the email sent succcesfully, however the page didn't redirect to thankoyu.html Can anybody please spot why?

TIA
Ant

APC
09-15-2008, 09:52 AM
I can't figure this out at all! :(

Vege
09-15-2008, 02:57 PM
have you checked for bom characters or other invisible output before the header redirect?
If this is a live host, have u tested the output when your error reporting is on to grab the error if it exists or have u checked the logs?

If you have ssh available running the file trough php -l filename.php would be the easiest parse error check.

erisco
09-15-2008, 03:59 PM
APC, I had an issue in the past where I had to write out the full url for the redirect to work. Because it worked and only a quick fix was necessary I never studied what was going wrong, but perhaps this suggestion could help you out too.