justhrun

cara_1.2.pehape

Aug 18th, 2014
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.52 KB | None | 0 0
  1. <?PHP
  2. // cara_1_2 : desentralisasi
  3. session_start();
  4.  
  5. if(isset($_POST['login'])){
  6.         include ("inc/koneksi.php");
  7.         $username=htmlentities((trim($_POST['username'])));
  8.         $password=htmlentities(md5($_POST['password']));
  9.         $level=htmlentities((trim($_POST['level'])));
  10.  
  11.         $kondisi = false;
  12.         $query  = "select id_admin from tabel_admin where username='$username' and password='$password' and level='$level'";
  13.         $result = mysql_query($query);
  14.         $rows = mysql_num_rows($result);
  15.  
  16.         if($rows==1) {  // hanya boleh ada 1row
  17.                 $kondisi = true;
  18.                 //daftarkan ID jika user dan password BENAR
  19.                 list($id_admin) = mysql_fetch_row($result);
  20.                 mysql_free_result($result);
  21.                 $_SESSION['id_admin']=$id_admin;
  22.                 $_SESSION['username']=$username;
  23.                 echo "<script> document.location.href='operator/home.php'; </script>";
  24.         }
  25.  
  26.         if(!$kondisi) {  // di tabel_admin gk valid, cek ke table dosen
  27.                 $query = "select nip from tabel_dosen where username='$username' and password='$password' and level='$level' ";
  28.                 $result = mysql_query($query);
  29.                 $rows = mysql_num_rows($result);
  30.  
  31.                 if($rows==1) {  // hanya boleh ada 1row
  32.                         $kondisi = true;
  33.                         //daftarkan ID jika user dan password BENAR
  34.                         list($nip) = mysql_fetch_row($result);
  35.                         mysql_free_result($result);
  36.                         $_SESSION['nip']=$id_admin;
  37.                         $_SESSION['username']=$username;
  38.                         echo "<script> document.location.href='dosen/index.php'; </script>";
  39.                 }
  40.         }
  41.  
  42.         if(!$kondisi) {  // di tabel_admin gk valid, cek ke table dosen
  43.                 $query = "select username from tabel_kondisi1 where username='$username' and password='$password' and level='$level' ";
  44.                 $result = mysql_query($query);
  45.                 $rows = mysql_num_rows($result);
  46.  
  47.                 if($rows==1) {  // hanya boleh ada 1row
  48.                         $kondisi = true;
  49.                         //daftarkan ID jika user dan password BENAR
  50.                         list($username) = mysql_fetch_row($result);
  51.                         mysql_free_result($result);
  52.                         $_SESSION['username']=$username;
  53.                         echo "<script> document.location.href='kondisi1/index.php'; </script>";
  54.                 }
  55.         }
  56.  
  57.         if(!$kondisi) {  // di tabel_admin gk valid, cek ke table dosen
  58.                 $query = "select username from tabel_kondisi2 where username='$username' and password='$password' and level='$level' ";
  59.                 $result = mysql_query($query);
  60.                 $rows = mysql_num_rows($result);
  61.  
  62.                 if($rows==1) {  // hanya boleh ada 1row
  63.                         $kondisi = true;
  64.                         //daftarkan ID jika user dan password BENAR
  65.                         list($username) = mysql_fetch_row($result);
  66.                         mysql_free_result($result);
  67.                         $_SESSION['username']=$username;
  68.                         echo "<script> document.location.href='kondisi2/index.php'; </script>";
  69.                 }
  70.         }              
  71.  
  72.         if(!$kondisi) { // gk ada yg match
  73.                 echo "<script> document.location.href='index.php?status=Password Anda salah!'; </script>";
  74.         }
  75.  
  76.         unset($_POST['login']);
  77. }
  78. ?>
Advertisement
Add Comment
Please, Sign In to add comment