I’m using this piece of code to display an error when the field is left empty but it just returns me to the location.
$err = array();
if(empty($native) )
{
$err[] = "ERROR - Enter Native Language";
//header("Location: language.php?msg=$err");
//exit();
if(!empty($err)) {
echo "<div class=\"msg\">";
foreach ($err as $e) {
echo "* $e <br>";
}
echo "</div>";
}
Any ideas?
What is up with the square bracket? if(empty($native ]))
You also need to reference the
$errarray element with an index.This should work
Also, its a good idea to url encode your strings as @Lawrence suggested 🙂