How do I redirect a page in PHP After User Submission?
Hi All...
I've created a basic comment/contact form and when I click the "Submit" button everything works fine and it sends off an email. Perfect. One problem though... It redirects to a new page and it echos a small "Thank You!" line. How do I get the user back to the contact form page on the web site (or any other page for that matter? I'll paste the short/simple PHP code below...
Any direction on this topic would be appreciated. Thanks!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Customer Inquiry</title>
</head>
<body><?php # Script 1.0 - contactlist.php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (!empty($_POST['first']) && !empty($_POST['last']) && !empty($_POST['email'])) {
$body = "First Name: {$_POST['first']}\nLast Name: {$_POST['last']}\nEMail Address: {$_POST['email']}\nContact Phone Number: {$_POST['phone']}\nContact Preference: {$_POST['contactvia']}\nBest Time To Contact: {$_POST['timepref']}\nComments:\n {$_POST['comment']}";
$body = wordwrap($body, 70);
mail('someone@someplace.net', 'NEW Customer Inquiry Submission',$body, "From: {$_POST['email']}");
echo '<p><em>Thank You for your Inquiry! We will respond to you ASAP!</em></p>';
$_POST = array();
} else {
echo '<p style="font-weight: bold; color: #C60">Please Fill Out The Form!</p>';
}
}
?>
</body>
</html>
