<?php
//error_reporting(0);
include "config/koneksi.php";
$pass=$_POST['password'];
//$level=$_POST['level'];
$username = $_POST['id_user'];
$login=mysql_query("SELECT * FROM tb_login
			WHERE username='".mysql_real_escape_string($username)."' AND password='$pass'");
$cocok=mysql_num_rows($login);
$r=mysql_fetch_array($login);

if ($cocok > 0){
	session_start();
	$_SESSION['id_user']     	= $r['id_user'];
	$_SESSION['namauser']     	= $r['username'];
	$_SESSION['email']    		= $r['email'];
  	$_SESSION['namalengkap']  	= $r['nama_lengkap'];
  	$_SESSION['passuser']     	= $r['password'];
  	$_SESSION['leveluser']    	= $r['level'];
	
	header('location:index.adm');
	}
else {
echo "<script>window.alert('Username atau Password anda salah.');
				window.location='administrator.php'</script>";
	}

?>
