Your form page should contain this
Code:
<form method="post" action="contact.php">
form fields
</form>
create a contact.php page in the same directory with the following code
PHP Code:
<?php
$EmailTo = "something@yourwebsite.com";
$xxxxx = Trim(stripslashes($_POST['xxxxx']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "xxxxx: ";
$Body .= $xxxxx;
$Body .= "\n";
// send email
$success = mail($EmailTo, $xxxxx, $Body);
?>
You should already have this. xxxxx being one of the fields, you probably have many more.
Anyway, simply add the following before the last ?>
PHP Code:
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
create the ok.htm page to your liking, this is the page the user is taken to after submiting the form.
It's also smart to creat an error.htm page that redirects a user to an error page if the form failed to send for any reason.