How do you send an HTML form processed by PHP to a success page after submission?

Elizabeth

New member
I have finally worked out how to handle an html form using php to upload a file and send it all to an e-mail address but I have one thing I can't work out. How do you send the user to a 'success' page after the form is submitted. So far the best I have managed to do is to echo a href link to the 'success' page which is displayed on a blank page. While this works, it doesn't look particularly attractive!

The part of the code I need to change is as follows:

// Send the message
$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
echo "<a href=\"/thankyou.html\">Mail sent!</a>";
} else {
echo "<p>Mail could not be sent. Sorry!</p>";
}
Daniel R - Thanks for your help! I tried doing that and it returned the error message

'Warning: Cannot modify header information - headers already sent'

Any ideas?


Ok finally after trawling through loads of forums I've got it to work using this:

// Send the message
$ok = @mail($to, $subject, $message, $headers);
if($ok){echo "<script>document.location.href='/thankyou.html'</script>";
echo "<script>'Content-type: application/octet-stream'</script>";}
else{
echo "<p>Mail could not be sent. Sorry!</p>";
 
Back
Top