Advertisement
Guest User

....

a guest
Jan 16th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <form action ="" method="post">
  2.  
  3. User Name:<br/>
  4. <input type='text' name='username' />
  5. <br/><br/>
  6. Password:<br/>
  7. <input type='password' name='password' />
  8. <br/><br/>
  9. <input type='submit' name='submit' value='login'>
  10. </form>
  11. <?php
  12.  
  13. if(isset($_POST['submit'])){
  14. $username = $_POST['username'];
  15.     $password = md5($_POST['password']);
  16.     $stmt = $con->prepare("SELECT username, password FROM users WHERE username=? AND  password=? LIMIT 1");
  17.     $stmt->bind_param('ss', $username, $password);
  18.     $stmt->execute();
  19.     $stmt->bind_result($username, $password);
  20.     $stmt->store_result();
  21.     if($stmt->num_rows == 1)  //To check if the row exists
  22.         {
  23.             while($stmt->fetch()) //fetching the contents of the row
  24.  
  25.               {$_SESSION['Logged'] = 1;
  26.                $_SESSION['username'] = $username;
  27.                echo 'Success!';
  28.                exit();
  29.                }
  30.  
  31.         }
  32.         else {
  33.             echo "INVALID USERNAME/PASSWORD Combination!";
  34.         }
  35.         $stmt->close();
  36.     }
  37.     else
  38.     {  
  39.  
  40.     }
  41. $con->close();
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement