How to Stay on Same Page after Submit in PHP

Program 1

<html>
    <head><title>User Login Application</title>
    <body>
<center>
   <form method=post action=userlogin.php>
    <table border=1>
        <tr>
            <th>User Name: </th>
            <td><input type=text name=txtuser></td>
        </tr>
        <tr>
            <th>Password: </th>
            <td><input type=password name=txtpass></td>
        </tr>
        <tr>
            <td></td>
            <td><input type=submit value=Submit name=submitbtn></td>
        </tr>
     <table>   
   </form>
<?php
         if(isset($_POST['submitbtn']))
        { 
              $user=$_POST['txtuser'];
              $pass=$_POST['txtpass'];
                // echo $user."<br>";
                // echo $pass."<br>";
             if((strcasecmp($user,"dataflair")==0) && (strcmp($pass,"indore")==0)) 
                  echo "<font color=green size=5>Valid user</font>";
              else
              echo "<font color=red size=5>Invalid User</font>";
        }   
       // Stduent 
?>
</center>
</body>
</html>
courses

Leave a Reply

Your email address will not be published. Required fields are marked *