Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- // cara_1_2 : desentralisasi
- session_start();
- if(isset($_POST['login'])){
- include ("inc/koneksi.php");
- $username=htmlentities((trim($_POST['username'])));
- $password=htmlentities(md5($_POST['password']));
- $level=htmlentities((trim($_POST['level'])));
- $kondisi = false;
- $query = "select id_admin from tabel_admin where username='$username' and password='$password' and level='$level'";
- $result = mysql_query($query);
- $rows = mysql_num_rows($result);
- if($rows==1) { // hanya boleh ada 1row
- $kondisi = true;
- //daftarkan ID jika user dan password BENAR
- list($id_admin) = mysql_fetch_row($result);
- mysql_free_result($result);
- $_SESSION['id_admin']=$id_admin;
- $_SESSION['username']=$username;
- echo "<script> document.location.href='operator/home.php'; </script>";
- }
- if(!$kondisi) { // di tabel_admin gk valid, cek ke table dosen
- $query = "select nip from tabel_dosen where username='$username' and password='$password' and level='$level' ";
- $result = mysql_query($query);
- $rows = mysql_num_rows($result);
- if($rows==1) { // hanya boleh ada 1row
- $kondisi = true;
- //daftarkan ID jika user dan password BENAR
- list($nip) = mysql_fetch_row($result);
- mysql_free_result($result);
- $_SESSION['nip']=$id_admin;
- $_SESSION['username']=$username;
- echo "<script> document.location.href='dosen/index.php'; </script>";
- }
- }
- if(!$kondisi) { // di tabel_admin gk valid, cek ke table dosen
- $query = "select username from tabel_kondisi1 where username='$username' and password='$password' and level='$level' ";
- $result = mysql_query($query);
- $rows = mysql_num_rows($result);
- if($rows==1) { // hanya boleh ada 1row
- $kondisi = true;
- //daftarkan ID jika user dan password BENAR
- list($username) = mysql_fetch_row($result);
- mysql_free_result($result);
- $_SESSION['username']=$username;
- echo "<script> document.location.href='kondisi1/index.php'; </script>";
- }
- }
- if(!$kondisi) { // di tabel_admin gk valid, cek ke table dosen
- $query = "select username from tabel_kondisi2 where username='$username' and password='$password' and level='$level' ";
- $result = mysql_query($query);
- $rows = mysql_num_rows($result);
- if($rows==1) { // hanya boleh ada 1row
- $kondisi = true;
- //daftarkan ID jika user dan password BENAR
- list($username) = mysql_fetch_row($result);
- mysql_free_result($result);
- $_SESSION['username']=$username;
- echo "<script> document.location.href='kondisi2/index.php'; </script>";
- }
- }
- if(!$kondisi) { // gk ada yg match
- echo "<script> document.location.href='index.php?status=Password Anda salah!'; </script>";
- }
- unset($_POST['login']);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment