Advertisement
Guest User

Untitled

a guest
Jun 6th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.23 KB | None | 0 0
  1. <?php
  2.  
  3. // Include database connection settings
  4. include("cek/dbconn.php");
  5. session_start();
  6.  
  7. if(isset($_POST['login'])){
  8. $username = $_POST['Username'];
  9. $password = $_POST['Password'];
  10.  
  11. // Retrieve username and password from database according to users input
  12. $sql = "SELECT Username, Password, Level_id, ST_id FROM userlogin WHERE Username = '$username' AND Password = '$password'";
  13. $login = mysqli_query($sql, $dbconn) or die ("Error: " . mysqli_error($dbconn));
  14.  
  15.  
  16. $row = mysqli_fetch_array($login);
  17. $status = $row['Level_id'];
  18.  
  19.  
  20.         if ($status == 'Admin'){
  21.         $_SESSION['Username'] = $row['Username'];
  22.         // Jump to secured page
  23.         header('Location: indexAdmin.php');
  24.         }
  25.  
  26.         elseif ($status == 'User'){
  27.         $_SESSION['Username'] = $row['Username'];
  28.         // Jump to secured page
  29.         header('Location: indexUser.php');
  30.         }
  31.  
  32.         elseif (($status == 'SuperuserP')||($status == 'SuperuserP')){
  33.         $_SESSION['Username'] = $row['Username'];
  34.         // Jump to secured page
  35.         header('Location: indexAdminPenang.php');
  36.         }
  37.         elseif (($status == 'penang')||($status == 'penang')){
  38.         $_SESSION['Username'] = $row['Username'];
  39.         // Jump to secured page
  40.         header('Location: indexUserPenang.php');
  41.         }
  42.  
  43.         elseif (($status == 'SuperuserK')||($status == 'SuperuserK')){
  44.         $_SESSION['Username'] = $row['Username'];
  45.         // Jump to secured page
  46.         header('Location: indexAdminKedahPerlis.php');
  47.         }
  48.         elseif (($status == 'userkp')||($status == 'userkp')){
  49.         $_SESSION['Username'] = $row['Username'];
  50.         // Jump to secured page
  51.         header('Location: indexUserKP.php');
  52.         }
  53.  
  54.         elseif (($status == 'SuperuserR')||($status == 'SuperuserR')){
  55.         $_SESSION['Username'] = $row['Username'];
  56.         // Jump to secured page
  57.         header('Location: indexAdminPerak.php');
  58.         }
  59.         elseif (($status == 'userR')||($status == 'userR')){
  60.         $_SESSION['Username'] = $row['Username'];
  61.         // Jump to secured page
  62.         header('Location: indexUserPerak.php');
  63.         }
  64.  
  65.         elseif ($username == '' && $password == '')
  66.         {
  67.             echo "<script type='text/javascript'>alert('Please fill the form!');location.href = 'index.php';</script>";
  68.         }
  69.         else
  70.         {
  71.             echo "<script type='text/javascript'>alert('Pengenalan/Kata Laluan salah');location.href = 'index.php';</script>";
  72.  
  73.         }
  74. }
  75.     mysqli_close();
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement