Advertisement
Guest User

Untitled

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