Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2. //Start session
  3. session_start();
  4. //Check whether the session variable SESS_MEMBER_ID is present or not
  5. if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '1')) {
  6. header("location: access-denied.php");
  7. exit();
  8. }
  9. ?>
  10.  
  11.  
  12.  
  13. <?php
  14. session_start(); // create a session
  15. ob_start(); // hold off sending page to the browser just yet...
  16.  
  17.  
  18. /// Connect to Database
  19. require_once ('db_connect.php');
  20.  
  21. /// Call the Table
  22. $tbl_name="tbl_accounts";
  23.  
  24. /// To protect MySQL injection
  25. $username = stripslashes($username);
  26. $password = stripslashes($password);
  27. $username = mysql_real_escape_string($username);
  28. $password = mysql_real_escape_string($password);
  29. $SESS_MEMBER_ID="SELECT Account_Level FROM tbl_accounts WHERE username='$username'";
  30.  
  31. /// Username and Password sent from form
  32. $username=$_POST['user'];
  33. $password=md5($_POST['pass']);
  34. $Account_Level="SELECT Account_Level FROM $tbl_name WHERE username='$username'";
  35.  
  36. $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
  37. $result=mysql_query($sql);
  38.  
  39. // Mysql_num_row is counting table row
  40. $count=mysql_num_rows($result);
  41. // If result matched $myusername and $mypassword, table row must be 1 row
  42.  
  43. if($count==1){
  44. // Register $username, $password and redirect to file "login_success.php"
  45. session_register("username");
  46. session_register("password");
  47. session_register("SESS_MEMBER_ID");
  48. header("location:index.php?pagelet=admins");
  49. ob_end_flush();
  50. }
  51. else {
  52. echo "Wrong Username or Password";
  53. header("location:index.php");
  54. ob_end_flush();
  55. }
  56.  
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement