so i'm making a contact form for some guy and I want it to give me an error message when some fields are empty. now it works and stuff, but it goes to blank page everytime. I've tried searching and couldn't find an answer. my php code:
<?php
$from = $_POST['email_adress'];
$subject = $_POST['subject'];
$select = $_POST['select'];
$message2 = $_POST['message2'];
$name = $_POST['firstname'];
$name2 = $_POST['lastname'];
if ($_POST['firstname'] == "")
{
echo "<script>
alert('A First Name is Mandatory');
</script>";
}
elseif ($_POST['subject'] == ""){
echo "<script>
alert('A Subject is Mandatory');
</script>";
}
elseif ($_POST['email_adress'] == "") {
echo "<script>
alert('An Email Adress is Mandatory');
</script>";
}
elseif ($_POST['message2'] == "") {
echo "<script>
alert('A Message is Mandatory');
<a href='contactus.html'>;
</script>";
} else {
$email_subject = "A submittion form";
$to ="sudaiguy1@gmail.com";
$headers = "From: sudaiguy1@gmail.com";
$email_body = 'You have been contacted by $name $name2 and his email is $from. \n The message he wanted to say was in the general subject of $select and more specifically $subject and the message is $message2';
mail($to,$email_subject,$email_body, $headers);
}
?>