Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include"config.php";
  4. //if there trying to login
  5. if(isset($_GET['login'])) {
  6. //removes sql injections from the data
  7. $username= htmlspecialchars(addslashes($_POST[username]));
  8. //encrypts the password
  9. $password = sha1(md5(md5(sha1(md5(sha1(sha1(md5($_POST[password]))))))));
  10. //gets the username data from the members database
  11. $uinfo = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error());
  12. //see if the user exists
  13. $checkuser = mysql_num_rows($uinfo);
  14. //if user name not found in database error
  15. if($checkuser == '0')
  16. {
  17. echo "Sorry, that username doesnt exist.";
  18. }else{
  19. //fetch the sql
  20. $udata = mysql_fetch_array($uinfo);
  21. //checks see if the account is verified
  22. if($udata[userlevel] == 1) {
  23. echo "Please verify your account.";
  24. }
  25. //if it is continue
  26. else
  27. //if the db password and the logged in password are the same login
  28. if($udata[password] == $password) {
  29. $query = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error());
  30. //fetchs the sql
  31. $user = mysql_fetch_array($query);
  32. //sets the logged session
  33. $_SESSION['id'] = "$user[id]";
  34. $_SESSION['password'] = "$user[password]";
  35. if($user[userlevel] == 0){
  36. echo"The account you are trying to access has been banned.";
  37. }else{
  38. echo "<center><img src='images/loading.gif'></center>"; //If you change the 0 below, maybe keep the loading image?
  39. //redirects them
  40. echo "<meta http-equiv='Refresh' content='0'/>"; //change the 0 to how long you want it to wait
  41. }
  42. }
  43. //wrong password
  44. else{
  45. echo "Unvalid username and password combination.";
  46. }
  47. }
  48. }else{
  49. //If not the above show the login form
  50. echo "Login form goes here";
  51. }
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement