I am trying to make a PHP form and check that text boxes are empty. My code:
<form method="post">
Name: <input type="text" name="name">
<span class="error">* <?php echo $nameErr;?></span>
//check user that fill in blank
if (empty($_POST["name"])) {
$nameErr = "Name is required";
}
Is this an effective way to check that the user filled in the blank? If user type "0", the system shows an error message.
Does anyone have a more efficient way?