Site icon DataFlair

GUI Login Application in PHP

Program 1

<html>
    <head><title>User Login Application</title>
    <body>
<center>
   <form method=post action="<?php echo $_SERVER['PHP_SELF']  ?>" >
    <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'];
               $mycon=mysqli_connect("localhost","root","","Library") or die("Connection not success");
               $sql="select * from login where username='".$user."' and password='".$pass."'" ;
               $record=$mycon->query($sql);
               if(mysqli_num_rows($record)>0)
               header("Location:FrontPage.php");
                else
                   echo "<font color=red size=5>Invalid userid or password</font>";
        }   
       
?>
</center>
</body>
</html>

 

Exit mobile version