Guest User

Untitled

a guest
Oct 7th, 2017
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     require_once('dbconfig/config.php');
  4.     //phpinfo();
  5. ?>
  6.  
  7. <!DOCTYPE html>
  8. <html>
  9. <head>
  10. <title>Login Page</title>
  11. <link rel="stylesheet" href="css/style.css">
  12. </head>
  13. <body style="background-color:#bdc3c7">
  14.     <div id="main-wrapper">
  15.     <center><h2>Login Form</h2></center>
  16.             <div class="imgcontainer">
  17.                 <img src="imgs/avatar.png" alt="Avatar" class="avatar">
  18.             </div>
  19.         <form action="index.php" method="post">
  20.        
  21.             <div class="inner_container">
  22.                 <label><b>Username</b></label>
  23.                 <input type="text" placeholder="Enter Username" name="username" required>
  24.                 <label><b>Password</b></label>
  25.                 <input type="password" placeholder="Enter Password" name="password" required>
  26.                 <button class="login_button" name="login" type="submit">Login</button>
  27.                 <a href="register.php"><button type="button" class="register_btn">Register</button></a>
  28.             </div>
  29.         </form>
  30.        
  31.         <?php
  32.             if(isset($_POST['login']))
  33.             {
  34.                 @$username=$_POST['username'];
  35.                 @$password=$_POST['password'];
  36.                 $query = "select * from userinfotbl where username='$username' and password='$password' ";
  37.                 //echo $query;
  38.                 $query_run = mysqli_query($con,$query);
  39.                 //echo mysql_num_rows($query_run);
  40.                 if($query_run)
  41.                 {
  42.                     if(mysqli_num_rows($query_run)>0)
  43.                     {
  44.                     $row = mysqli_fetch_array($query_run,MYSQLI_ASSOC);
  45.                    
  46.                     $_SESSION['username'] = $username;
  47.                     $_SESSION['password'] = $password;
  48.                    
  49.                     header( "Location: homepage.php");
  50.                     }
  51.                     else
  52.                     {
  53.                         echo '<script type="text/javascript">alert("No such User exists. Invalid Credentials")</script>';
  54.                     }
  55.                 }
  56.                 else
  57.                 {
  58.                     echo '<script type="text/javascript">alert("Database Error")</script>';
  59.                 }
  60.             }
  61.             else
  62.             {
  63.             }
  64.         ?>
  65.        
  66.     </div>
  67. </body>
  68. </html>
Add Comment
Please, Sign In to add comment