Guest User

Untitled

a guest
Nov 22nd, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. <?php
  2. if(isset($_SESSION['access']) != 'admin'){
  3. header('location:index.php');
  4. }
  5. if(isset($_SESSION['username']) && isset($_SESSION['kelass'])){
  6. $user = $_SESSION['username'];
  7. $kelas = $_SESSION['kelass'];
  8. $query = mysqli_query($con,"SELECT * FROM piket WHERE
  9. kelas = '$kelas' ORDER BY tgl_piket DESC");
  10.  
  11. }else {
  12. header('location:login.php');
  13. }
  14. ?>
  15.  
  16. if(isset($_SESSION['access']) != 'user'){
  17. header('location:indexp.php');
  18. }
  19.  
  20. if(isset($_SESSION['username']) && isset($_SESSION['kelass'])){
  21. $user = $_SESSION['username'];
  22. $kelas = $_SESSION['kelass'];
  23. if (date('D')=='Mon') {
  24. $query = mysqli_query($con,"SELECT * FROM siswa where hari='senin' and kelas='$kelas' ORDER BY no ASC");
  25. $haridb="senin";
  26. }
  27.  
  28. elseif (date('D')=='Tue') {
  29. $query = mysqli_query($con,"SELECT * FROM siswa where hari='selasa' and kelas='$kelas' ORDER BY no ASC");
  30. $haridb="selasa";
  31. }
  32.  
  33. elseif (date('D')=='Wed') {
  34. $query = mysqli_query($con,"SELECT * FROM siswa where hari='rabu' and kelas='$kelas' ORDER BY no ASC");
  35. $haridb="rabu";
  36. }
  37.  
  38. elseif (date('D')=='Thu') {
  39. $query = mysqli_query($con,"SELECT * FROM siswa where hari='kamis' and kelas='$kelas' ORDER BY no ASC");
  40. $haridb="kamis";
  41. }
  42.  
  43. elseif (date('D')=='Fri') {
  44. $query = mysqli_query($con,"SELECT * FROM siswa where hari='jumat' and kelas='$kelas' ORDER BY no ASC");
  45. $haridb="jumat";
  46. }
  47.  
  48.  
  49. }else {
  50. header('location:login.php');
  51. }
  52.  
  53. if(isset($_POST['submit'])){
  54. $username = $_POST['username'];
  55. $password = md5($_POST['password']);
  56. $query = mysqli_query($con, "SELECT * FROM users WHERE username = '$username' and password = '$password'");
  57. $gettype = mysqli_fetch_assoc($query);
  58.  
  59. echo $gettype['access'];
  60. $check = mysqli_num_rows($query);
  61.  
  62. if ($check > 0) {
  63. if($gettype['access']=='user'){
  64. $_SESSION['access'] = 'user';
  65. $_SESSION['username'] = $gettype['username'];
  66. header('location:index.php');
  67.  
  68.  
  69. }
  70. else if ($gettype['access']=='admin') {
  71. $_SESSION['access']== 'admin';
  72. $_SESSION['username'] = $gettype['username'];
  73. $_SESSION['admin'] = 1;
  74. header('location:indexp.php');
  75.  
  76.  
  77. }
  78. }
  79. }
Add Comment
Please, Sign In to add comment