Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2.  
  3. $username = $_POST['username'];
  4. $password = $_POST['password'];
  5.  
  6. if ($username && $password)
  7. {
  8.  
  9.     $connect = mysql_connect("localhost", "root", "7c8wc3") or die("Could not connect!");
  10.     mysql_select_db("phplogin") or die ("could not find database");
  11.    
  12.     $query = mysql_query("SELECT * FROM users WHERE username='$username'");
  13.    
  14.     $numrows = mysql_num_rows($query);
  15.    
  16.     if ($numrows!=0)
  17.     {
  18.      
  19.        while ($row = mysql_fetch_accoc($query))
  20.        {
  21.              $dbusername = $row['username'];
  22.              $dbpassword = $row['password'];
  23.        }
  24.        
  25.        // check to see if they match!
  26.        if ($username==$dbusername&&$password==$dbpassword)
  27.        {
  28.           echo "You are in!";
  29.        }
  30.        else
  31.        {
  32.           echo "Incorrect password";
  33.        }
  34.     }
  35.     else
  36.     {
  37.         die("That user doesn't exist!");
  38.     }
  39. }
  40. else
  41. {
  42.     die("Please enter a username and password");
  43. }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement