<?
session_start();
//$isi = $_POST['isi'];

$kete = $_GET['kete'];
$usr=$_POST['user'];
$psw=$_POST['pass'];
//$origin = $_POST[origin];
//$orinya = $origin;


include "plg/kon.php";
$sql 			= "select * from user where user='$usr' and pass='$psw'";
$result 	= $conn->query($sql);
while($r 	= $result->fetch_assoc()){
	$grp 		= $r['grp'];
	$nama 	= $r['nama'];
	$usrdb 	= $r['user'];
	$passwd 	= $r['pass'];
}
//$ketelogin = $_SESSION['grup'];

//mysql_close();

if ($grp=='admin' and $usrdb==$usr){
	$_SESSION['grup']=$grp;
	$_SESSION['user']=$usrdb;
	$_SESSION['nama']=$nama;
	$_SESSION['pass']=$passwd;
	header("location:dashboard/index.php");
}
elseif($grp=='user' and $usrdb==$usr){
	$_SESSION['grup']=$grp;
	$_SESSION['user']=$usrdb;
	$_SESSION['nama']=$nama;
	$_SESSION['pass']=$passwd;
	header("location:dashboarduser/index.php");
}
else{
	$_SESSION['grup']='';
	header("location:index.php");
}

?>
