Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * @author Jason
  5. * @copyright 2010
  6. */
  7.  
  8. $username = $_POST['username'];
  9. $password = $_POST['password'];
  10.  
  11. if ($username&&$password) {
  12.  
  13. $connect = mysql_connect("localhost","root","jason") or die("Cannot connect to database!");
  14. mysql_select_db("usersystem") or die("Cannot connect to database!");
  15.  
  16. $query = mysql_query("SELECT * FROM users WHERE username='$username'");
  17.  
  18. $numrows = mysql_num_rows($query);
  19.  
  20. if (numrows!=0) {
  21.  
  22. while ($r = mysql_fetch_assoc($query)) {
  23.  
  24. $dbusername = $r['username'];
  25. $dbpassword = $r['password'];
  26.  
  27. }
  28.  
  29. if ($username==$dbusername&&$password==$dbpassword) {
  30.  
  31. echo "You're in!";
  32.  
  33. } else
  34. echo "Incorrect Password";
  35.  
  36. } else
  37. die("Username doesn't exist!");
  38.  
  39. } else
  40. die("Please enter a username and password.");
  41.  
  42. ?>
  43.  
  44. <html>
  45.  
  46. <form action='index.php' method='POST'>
  47.  
  48. Username: <input type="text" name="username"/><br />
  49. Password: <input type="password" name="password"/><br />
  50.  
  51. <input type="submit" value="Log in"/>
  52.  
  53. </form>
  54.  
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement