Advertisement
Guest User

Untitled

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