Guest User

Untitled

a guest
Mar 24th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. if(isset($_POST['btn-login']))
  2. {
  3. $email = trim($_POST['txtemail']);
  4. $upass = trim($_POST['txtupass']);
  5.  
  6.  
  7. $stmt = $user_login->runQuery("SELECT * FROM jusers WHERE jemail=:email_id");
  8. $stmt->execute(array(":email_id"=>$email));
  9. $userRow=$stmt->fetch(PDO::FETCH_ASSOC);
  10.  
  11. if($stmt->rowCount() == 1)
  12. {
  13.  
  14. if($userRow['jpass']==md5($upass))
  15. {
  16.  
  17. $_SESSION['user']= array(
  18. 'juid' =>$userRow['juid'],
  19. 'username'=>$userRow['jemail'],
  20. 'password'=>$userRow['jpass'],
  21. 'role'=>$userRow['role']
  22. );
  23.  
  24. $role= $_SESSION['user']['role'];
  25.  
  26. switch ($role) {
  27.  
  28. case 'admin':
  29.  
  30. header("Location : super_admin.php");
  31. break;
  32.  
  33. case 'user' :
  34.  
  35. header("Location : admin_user.php");
  36. break;
  37. }
  38.  
  39.  
  40. }
  41. else
  42. {
  43.  
  44. $errMSG =" <div class='alertmsg alert'>
  45. <a class='clostalert'>close</a>
  46. <strong>Warning!</strong> Wrong password </div> ";
  47. }
  48.  
  49. }
  50. else
  51. {
  52.  
  53. $errMSG = " <div class='errormsg alert'>
  54. <a class='clostalert'>close</a>
  55. <strong>Error!</strong> Wrong credentials!</div> ";
  56. }
  57.  
  58. <?php
  59.  
  60. session_start();
  61. require_once 'class.user.php';
  62. $admin_user = new USER();
  63.  
  64. if(empty($_SESSION['user'])){
  65.  
  66. header('location:login.php');
  67.  
  68. }
  69.  
  70. if($_SESSION['user']['role']=='admin'){
  71.  
  72. header('location:super_admin.php');
  73.  
  74. }
  75.  
  76.  
  77. if(!$admin_user->is_logged_in())
  78. {
  79. $admin_user->redirect('login.php');
  80. }
  81.  
  82. $sid = $_SESSION['user']['juid'];
  83.  
  84. $stmt = $admin_user->runQuery('select jname from jusers where juid = :sid');
  85. $stmt->bindParam(':sid', $sid);
  86. $stmt->execute();
  87.  
  88. while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
  89.  
  90. extract($row);
  91.  
  92. }
  93.  
  94. ?>
Add Comment
Please, Sign In to add comment