<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Register Page</title>
<link rel="stylesheet" href="css/form.css">
</head>
<body>
<?php
$submit = $_POST["submit"];
$fullName = $_POST["fullname"];
if(isset($submit)) {
if (empty($fullname)) {
array_push($errors, "All fields are required!");
}
if (count($errors)>0) {
foreach($errors as $error) {
echo $error;
}
}
else{
//pass
}
}
?>
<form class="form" action="registeration.php" method="post">
<h1 class="heading">Register</h1>
<input type="text" placeholder="name" name="fullname" autocomplete="off" class="name"/>
<input type="submit" name="submit" value="register"/>
</form>
</body>
</html>
if i run it then It shows "All fields are required!" before i click the button
i want to show it as error it should show only if someone click the button who forget/didn't enter the name gets the error "All fields are required!"