Guest User

Untitled

a guest
Mar 28th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST['username']) && isset ($_POST['password']))
  4. {
  5.     $username = $_POST['username'];
  6.     $password = $_POST['password'];
  7.    
  8.     $hashedPassword = password_hash($password,PASSWORD_DEFAULT);
  9.    
  10.     //require"databaseConfig.php";
  11.    
  12.     $sql = "select * from userreg where UserName = '$username'";
  13.    
  14.     require"databaseConfig.php";
  15.    
  16.     $qryResult = mysqli_query($conn, $sql);
  17.  
  18.    
  19.     if (mysqli_num_rows($qryResult) > 0){      
  20.         while($row = mysqli_fetch_assoc($qryResult)) {
  21.             if(password_verify($password, $row['password']))
  22.             {
  23.                 echo "Hello there $username <br>";
  24.             }
  25.            
  26.             else {
  27.                 echo "Password is incorrect <br>";
  28.             }
  29.            
  30.         }
  31.        
  32.     }  else
  33.         {
  34.        
  35.         echo "0 results";
  36.        
  37.         }
  38.    
  39. }
  40.    
  41.         else{
  42.    
  43.             echo "Error, username or password missing!";
  44.             }
  45.    
  46.    
  47.  
  48.  
  49. ?>
Add Comment
Please, Sign In to add comment