Advertisement
Guest User

login

a guest
Apr 23rd, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. //===========================proses login=======================================
  2. <?php
  3.     include("../koneksi.php");
  4.     $usr        = $_POST['username'];
  5.     $pwd        = md5($_POST['password']);
  6.  
  7.     $user       = stripcslashes($usr);
  8.     $password   = stripcslashes($pwd);
  9.  
  10.     $query  = "SELECT * FROM user where username = '$user' and password = '$password'";
  11.     $sql = mysqli_query($koneksi,$query) or die(mysqli_error());
  12.  
  13.     $hitung = mysqli_fetch_array($sql,MYSQLI_ASSOC);
  14.     mysqli_close($koneksi);
  15.    
  16.  
  17.     if($hitung['Status'] == 'admin'){
  18.         $_SESSION['user'] = $pengguna;
  19.         header('location: ../utama.php');
  20.     }
  21.     else if($hitung['Status'] == 'kepsek'){
  22.         $_SESSION['user'] = $pengguna;
  23.         header('location: ../utama.php');
  24.     }
  25.    
  26.     else{
  27.         echo "username atau password salah, silahkan <a href='../index.php'>coba lagi</a>";
  28.     }
  29.  
  30.  ?>
  31.  
  32. //=============================halaman admin===========================================
  33. <?php
  34.     include("koneksi.php");
  35.     session_start();
  36.     if(isset($_SESSION['pengguna'])){
  37.         header('location:index.php');
  38.     }
  39.     print_r($_SESSION['pengguna']) ;
  40.  
  41. ?>
  42. <html>...........</html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement