Create a form to accept the name of the user as input as shown.
If the user leaves the inputbox blank then it should display error as shown
and if user enters name then it should display as shown below
.error{*****:#FF0000} <?php $name = ""; $nameErr = ""; $flag=0; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $flag=1; } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> " method="post"> Name: * <?php echo $nameErr;?> <?php if($flag==1) { echo "Hello".test_input($_POST["name"]); } ?>