Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 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("databasehost", "databaseusername", "databasepassword") or die("Couldnt connect!");
  10. mysql_select_db("databasename") or die("Couldn't find db");
  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_assoc($query));
  20. {
  21.   $dbusername = $row['username'];
  22.   $dbpassword = $row['password'];
  23. }
  24. // check to see if they match
  25. if ($username==$dbusername&&$password==$dbpassword)
  26. {
  27.   echo "You're in!";
  28. }
  29. else
  30.     echo "Incorrect password!";
  31. }
  32. else
  33.     die("That user doesn't exsist!");
  34.  
  35.  
  36. }
  37. else
  38.     die("Please enter a username and a password!");
  39.  
  40.  
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement