This is my html code.
<HTML>
<head>STUDENT LOGIN</head>
<style>
.error { color: #FF0000; }
</style>
<body>
<p><span class ="error">* required field.</span></p>
<?php
class data
{
    static $passwordErr="";
    static $password="";
    static $classError="";
    static $Studentclass=0;
    static $nameErr="";
    static $Studentname="";
}
?>
<form method="POST" action=<?php echo ($_SERVER["PHP_SELF"]);?>>
 NAME: <input type="text" name="NAME" ;?>
 <span class="error">* <?php echo data::$nameErr    ;?></span><br>
 CLASS:<input type="text" name="CLASS" ?>
 <span class="error">* <?php echo  data::$classError             ;?> </span> 
 <br>
 PASSWORD:<input type="password" name="PASSWORD" ?>
 <span class="error">* <?php echo  data::$passwordErr               ;?> 
 </span><br>
 <input type="submit" name="LOGIN" >
 <?php
 if($_SERVER["REQUEST_METHOD"]=="POST") {
    data::$Studentname=$_POST['NAME'];
    if(empty($_POST['NAME'])) {
        data::$nameErr="Name cannot be empty";
    }
    elseif (!preg_match("/^[a-zA-Z]*$/",data::$Studentname)) {
        data::$nameErr="Name can contain only letters and whitespaces";
    }
    data::$Studentclass=0;
    data::$Studentclass=filter_input(INPUT_POST,data::$Studentclass,FILTER_VALIDATE_ INT);
    if(empty(data::$Studentclass)) {
        data::$classError = "Class cannot be empty";
    }
    data::$password="";
    data::$password=$_POST['PASSWORD'];
    if(empty(data::$password)) {
        data::$passwordErr="Password cannot be empty";
    }
 }
 ?>
 </form>
 </body>
 </HTML>
So according to the code i have written it will show respective errors if i enter an empty value or enter numbers instead of name and so on. But when i run this file..it does not show any error. Can anyone explain why this is happening and how i could fix it
 
     
    