Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // cara_1 : desentralisasi
- session_start();
- if(isset($_POST['login'])){
- include ("inc/koneksi.php");
- $username=htmlentities((trim($_POST['username'])));
- $password=htmlentities(md5($_POST['password']));
- $is_admin = true;
- $query = "select id_admin from tabel_admin where username='$username' and password='$password'";
- $result = mysql_query($query);
- $rows = mysql_num_rows($result);
- if($rows!=1) { // hanya boleh ada 1row
- $is_admin = false;
- } else {
- //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(!$is_admin) { // di tabel_admin gk valid, cek ke table dosen
- $query = "select nip from tabel_dosen where username='$username' and password='$password'");
- $result = mysql_query($query);
- $rows = mysql_num_rows($result);
- if($rows!=1) { // hanya boleh ada 1row
- echo "<script> document.location.href='index.php?status=Username/Password Anda salah!'; </script>";
- } else {
- //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>";
- }
- }
- unset($_POST['login']);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment