联系表单失败时显示错误消息

I have a contact form which send a email with the fields that are filled in. Only if the fields are empty than there is a error message that there are fields missing. The problem is that the errormessage doesn't show on the page.

This is my php page.

<?php
if (isset($_POST['submit'])) {
$body = '';

$body .= 'Naam: ' . $_POST['naam'] . "
";
$body .= 'Telefoon: ' . $_POST['telefoon'] . "
";
$body .= 'Email: ' . $_POST['email'] . "
";
$body .= 'Bericht: ' . $_POST['bericht'] . "
";
$body .= 'Adres: ' . $_POST['adres'] . "
";

if (($_POST['naam'] &&  $_POST['email'] &&  $_POST['bericht'] && $_POST['telefoon'] !=""))
{
mail('someone@mail.com', 'Contact Form', $body, 'From:     no-reply@mycompany.com');
header( "Location: /bedankt.html");
}
else
{
$naamErr = $berichtErr = $emailErr = $telefoonErr = $errormessage = "";
$errormessage = "De volgende velden waren niet ingevuld: ";
if($_POST['naam'] == "")
{
$errormessage .= "naam,";
}
if($_POST['bericht'] == "")
{
$errormessage .= "bericht,";
}
if($_POST['email'] == "")
{
$errormessage .= "email,";
}
if($_POST['telefoon'] == "")
{
$errormessage .= "telefoon";
}

header( "Location: contact.html?errormessage=$errormessage");
}
}


?>

On the redirected page I use a $_GET function to call the querystring.

<?php print $_GET["errormessage"];?>

What am I doing wrong because tthe errormessage isn't shown.

You can't get $_GET in html page.

You need php page to do that.

create contact.php instead of contact.html.

and try this:

header( "Location: contact.php?errormessage=$errormessage");

Where you are writing <?php print $_GET["errormessage"];?> as i can see you are redirecting threw header to "contact.html" with below code header( "Location: contact.html?errormessage=$errormessage");

On html page we can not use php $_GET["errormessage"]