Advertisement
Guest User

login

a guest
Oct 9th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <?php session_start();
  2.  
  3.  
  4.  include 'koneksi.php';
  5. if (isset($_POST['username']) && isset($_POST['password']))
  6.  {
  7.      $username = mysqli_real_escape_string($conn, $_POST['username']);
  8.      $password = md5(mysqli_real_escape_string($conn, $_POST['password']));
  9.      $result = mysqli_query($conn, "SELECT * FROM tb_user WHERE u_username='$username' and u_password='$password'");
  10.      $count = mysqli_num_rows($result);
  11.      $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
  12.      
  13.  
  14.  if($row['level'] == 1){
  15.             $_SESSION['login_user']=$username;
  16.             echo '<script language="javascript">alert("Anda berhasil Login Admin!"); document.location="inventory/index.php";</script>';
  17.            
  18.         }else if($row['level'] == 2){
  19.             $_SESSION['login_user']=$username;
  20.         echo '<script language="javascript">alert("Anda berhasil Login Admin!"); document.location="pengiriman/index.php";</script>';
  21.         }else if($row['level'] == 3){
  22.             $_SESSION['login_user']=$username;
  23.             echo '<script language="javascript">alert("Anda berhasil Login Admin!"); document.location="general/index.php";</script>';
  24.            
  25.         }else
  26.        
  27.         {  
  28.    
  29.         echo '<script language="javascript">alert("Maaf Username Password anda salah!"); document.location="index.php";</script>';
  30.        
  31.        
  32.    
  33.          
  34.      }  
  35.   } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement