Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Include database connection settings
- include("cek/dbconn.php");
- session_start();
- if(isset($_POST['login'])){
- $username = $_POST['Username'];
- $password = $_POST['Password'];
- // Retrieve username and password from database according to users input
- $sql = "SELECT Username, Password, Level_id, ST_id FROM userlogin WHERE Username = '$username' AND Password = '$password'";
- $login = mysqli_query($sql, $dbconn) or die ("Error: " . mysqli_error($dbconn));
- $row = mysqli_fetch_array($login);
- $status = $row['Level_id'];
- if ($status == 'Admin'){
- $_SESSION['Username'] = $row['Username'];
- // Jump to secured page
- header('Location: indexAdmin.php');
- }
- elseif ($status == 'User'){
- $_SESSION['Username'] = $row['Username'];
- // Jump to secured page
- header('Location: indexUser.php');
- }
- elseif (($status == 'SuperuserP')||($status == 'SuperuserP')){
- $_SESSION['Username'] = $row['Username'];
- // Jump to secured page
- header('Location: indexAdminPenang.php');
- }
- elseif (($status == 'penang')||($status == 'penang')){
- $_SESSION['Username'] = $row['Username'];
- // Jump to secured page
- header('Location: indexUserPenang.php');
- }
- elseif (($status == 'SuperuserK')||($status == 'SuperuserK')){
- $_SESSION['Username'] = $row['Username'];
- // Jump to secured page
- header('Location: indexAdminKedahPerlis.php');
- }
- elseif (($status == 'userkp')||($status == 'userkp')){
- $_SESSION['Username'] = $row['Username'];
- // Jump to secured page
- header('Location: indexUserKP.php');
- }
- elseif (($status == 'SuperuserR')||($status == 'SuperuserR')){
- $_SESSION['Username'] = $row['Username'];
- // Jump to secured page
- header('Location: indexAdminPerak.php');
- }
- elseif (($status == 'userR')||($status == 'userR')){
- $_SESSION['Username'] = $row['Username'];
- // Jump to secured page
- header('Location: indexUserPerak.php');
- }
- elseif ($username == '' && $password == '')
- {
- echo "<script type='text/javascript'>alert('Please fill the form!');location.href = 'index.php';</script>";
- }
- else
- {
- echo "<script type='text/javascript'>alert('Pengenalan/Kata Laluan salah');location.href = 'index.php';</script>";
- }
- }
- mysqli_close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement