Advertisement
Guest User

Untitled

a guest
Feb 21st, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 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.  
  11. $connect = mysql_connect("192.168.0.17","root","***************") or die ("Unable to connect to MySQL! Contact the admin.");
  12. mysql_select_db("login") or die ("Unable to find to database! Contact the admin.");
  13.  
  14. $query = mysql_query("SELECT * FROM users WHERE username='$username'");
  15.  
  16. $numrows = mysql_num_rows($query);
  17. if ($numrows !=0)
  18. {
  19.  
  20. while ($row = mysql_fetch_assoc($query))
  21. {
  22.  
  23. $dbusername = $row['username'];
  24. $dbpassword = $row['password'];
  25.  
  26. }
  27. if ($username==$dbusername&&$password==$dbpassword)
  28. {
  29.  
  30. echo "Logged in! <a href='membersarea'>click here to enter the members area</a>"
  31. $_SESSION['username']=$dbusername;
  32.  
  33. }
  34. else
  35. echo "Incorrect username and/or password.";
  36. }
  37.  
  38. else
  39. die ("Incorrect username and/or password.");
  40. }
  41. else
  42. die ("Please enter a username and password")
  43.  
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement