Advertisement
Guest User

Untitled

a guest
Jun 18th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. $username = $_POST["username"];
  6. $password = $_POST["password"];
  7.  
  8. if (isset($username) && isset($password))
  9. {
  10.  
  11. $connect = mysql_connect("localhost","root","usbw") or die("Couldn't connect!");
  12. mysql_select_db("phplogin") or die ("couldn't find db!");
  13.  
  14. $query = mysql_query("SELECT * FROM users WHERE username='$username'");
  15.  
  16. $numrows = mysql_num_rows($query);
  17.  
  18. if ($numrows!=0)
  19. {
  20.  
  21. while ($row = mysql_fetch_assoc($query))
  22. {
  23. $dbusername = $row['username'];
  24. $dbpassword = $row['password'];
  25. }
  26.  
  27. // check to see if they match!
  28. if ($username==$dbusername&&$password==$dbpassword)
  29. {
  30. echo "You're in! <br><a href='member.php'>Click here</a> to enter the member page.";
  31. $_SESSION['username'] = $dbusername;
  32. }
  33. else
  34. {
  35. echo "Incorrect password!";
  36. }
  37. }
  38. else
  39. {
  40. die("That user doesn't exist!");
  41. }
  42. }
  43. else
  44. {
  45. die("Please enter and username and password!");
  46. }
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement