I wrote a php contact form but I can't figure out how to redirect a user to a different page...
Here is my code:
<?php
if($_POST){
$name = $_POST['name']; //gets the entered name
$email = $_POST['email']; //gets the entered email address
$subject = $_POST['subject']; //gets the subject
$message = $_POST['message']; //gets the entered message
$headers = "From: $email \n"; //Set from email address
$to = "email@gmail.com"; //Set email address
//validating the fields if any empty
if($name != "" && $email != "" && $subject != "" && $message != ""){
mail($to,$subject,$message,$headers); //calling php mail function
} else
{
echo "Please fill in all fields and submit again!";
}
}
?>
<?php
$email_from = 'email@gmail.com.com';
$email_subject = "New Form submission - $subject"; // Change the message subject here
$email_body = "You have received a new message from $name ($phone) .\n Here is the message:\n $message. His/Her full contact information is: \n $name \n $email \n 1$phone.";
// Send The Email
$to = "email@gmail.com"; // Set valid email address to send the form to
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
?>