Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. isvalid.php
  2.  
  3. <?php
  4. session_start();
  5. include('includes/confi.php');
  6. include("session.php");
  7. $eid = $_SESSION['employee_id'];
  8. $sql = "SELECT * FROM employee WHERE employee_id = :eid";
  9. $query = $dbh->prepare($sql);
  10. $query->bindParam(':eid', $eid, PDO::PARAM_STR);
  11. $query->execute();
  12. if($_SESSION['empid']=="")
  13. {
  14. $_SESSION['msg']="Access Denied";
  15. header("location:index.php");
  16. }
  17. ?>
  18.  
  19. do_login.php
  20.  
  21. <?php include('includes/confi.php');
  22. if(isset($_POST["submit"])){
  23. $empid=$_POST["empid"];
  24. $pass=$_POST["password"];
  25. $sql= "UPDATE `employee` SET status = 1 WHERE empid= :empid and
  26. password = :pass ";
  27. $query = $dbh->prepare($sql);
  28. $query->bindParam(':empid',$empid,PDO::PARAM_STR);
  29. $query->bindParam(':pass',$pass,PDO::PARAM_STR);
  30. $query->execute();
  31. $sql = "SELECT employee_id, fname, lname, empid, email, password,
  32. status, role, team, teamcode FROM employee where empid = :empid and
  33. password = :pass";
  34. $query = $dbh->prepare($sql);
  35. $query->bindParam(':empid', $empid, PDO::PARAM_STR);
  36. $query->bindParam(':pass', $pass, PDO::PARAM_STR);
  37. $query->execute();
  38. $row = $query->fetch(PDO::FETCH_BOTH);
  39. if(is_array($row))
  40. {
  41. session_start();
  42. $_SESSION["empid"]=$empid;
  43. $_SESSION["role"]=$row["role"];
  44. $_SESSION["eid"]=$row["empid"];
  45. $_SESSION["status"]=$row['status'];
  46. $_SESSION["employee_id"]=$row['employee_id'];
  47. $_SESSION['uname']=$row['fname']." ".$row['lname'];
  48. $_SESSION['team']=$row['team'];
  49. $_SESSION['teamcode']=$row['teamcode'];
  50. $_SESSION['email']=$row['email'];
  51. if($_SESSION["role"]=='admin' ){
  52. $_SESSION['alogin']=$_POST['empid'];
  53. header("Location:admin/home.php");
  54. }
  55. elseif($_SESSION["role"]=='aam' ){
  56. $_SESSION['tlogin']=$_POST['empid'];
  57. header("Location:aam/home.php");
  58. }
  59. elseif($_SESSION["role"]=='TL' ){
  60. $_SESSION['tlogin']=$_POST['empid'];
  61. header("Location:TL/home.php");
  62. }
  63. else{
  64. $_SESSION['emplogin']=$_POST['empid'];
  65. header("Location:home.php");
  66. }
  67. }
  68. else{
  69. echo "<script>
  70. alert('Employee ID or Password Incorrect');
  71. window.location.href='index.php';
  72. </script>";
  73. }
  74. }
  75. ?>
  76.  
  77. <?php
  78. include("isvalid.php");
  79. echo "This is Home Page";
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement