Advertisement
Guest User

Untitled

a guest
May 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php
  2. switch($_GET['s'])
  3. {
  4. case 'auth':
  5. auth();
  6. break;
  7.  
  8. default:
  9. 'login';
  10. }
  11. function login()
  12. {
  13. global $c,$ir;
  14. if($_SESSION['loggedin'] == "1")
  15. {
  16. print"You are already logged in {$ir['username']}";
  17. exit;
  18. }
  19. else
  20. {
  21. print "<Form Action='index.php?p=login&s=auth' method='post'>
  22. Username: <input type='text' name='username'> <br />
  23. Password: <input type='password' name='password'> <br />
  24. <input type='submit' value='Login'></form>";
  25. }
  26. }
  27. function auth()
  28. {
  29. global $c,$ir;
  30. $pass=md5($_POST['password']);
  31. $q=mysql_query("SELECT * FROM users WHERE username='{$_POST['username']}' AND userpass='$pass'",$c);
  32. if(!$_POST['username'] || !$_POST['password'])
  33. {
  34. print "You must enter a username and password."
  35. exit;
  36. }
  37. if(!mysql_num_rows($q))
  38. {
  39. print "Invalid username/password";
  40. exit;
  41. }
  42. if($_SESSION['loggedin'] == "1")
  43. {
  44. print"You are already logged in {$ir['username']}";
  45. exit;
  46. }
  47. else
  48. {
  49. $r=mysql_fetch_array($q);
  50. $_SESSION['loggedin']=1;
  51. $_SESSION['user']=$r['userid'];
  52. print "You have successfully logged in {$r['username']}.";
  53. }
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement