I have a PHP contact form, and once a user has successfully filled out the form they see the "Message sent" message under the form.
PHP code
<?php
if(isset($_POST['submit']) && !isset($name_error) && !isset($subject_error) && !isset($email_error) && !isset($message_error)){
$to = 'youremail@addres.com'; // edit here
$body = " Name: $name\n E-mail: $email\n Message:\n $message";
if(mail($to, $subject, $body)){
echo '<p style="color: green">Message sent</p>';
}else{
echo '<p>Error occurred, please try again later</p>';
}
}
?>
However, refreshing the form after the form has been submitted the page would send the form details again and again. How can I redirect a user to say: http://www.example.com/thanks
after they have submitted the form successfully?
EDIT: I am not sure how to redirect within the form itself, I know how to redirect with PHP, just not in this script.