<?php
	include("koneksi.php");

	$user = $_POST['username'];
	$pass = md5($_POST['password']);

	//cek user
	$login="SELECT * FROM admin WHERE username='$user' AND password='$pass'";
	$cek=mysql_query($login) or die(mysql_error());
	$isi=mysql_fetch_array($cek);
	$jml=mysql_num_rows($cek);
	
	if($jml == 1)
	{
		session_start();
		$_SESSION['username'] = $isi['username'];
		//$_SESSION['level'] = $isi['level'];
		
		$user = $_SESSION['username'];
		//$level = $_SESSION['level'];
		echo "<meta http-equiv='refresh' content='0; url=../index.php'>";
	}
	else if ($_POST['username']=='' && $_POST['password']=='')
	{
	?>
		<script type="text/javascript">
			alert("Password dan Username tidak boleh kosong...!!!");
		</script>
	<?php
		echo "<meta http-equiv='refresh' content='0; url=../login.php'>";
	}
	else
	{
	?>
		<script type="text/javascript">
			alert("Password dan Username tidak Valid...!!!");
		</script>
	<?php
		echo "<meta http-equiv='refresh' content='0; url=../login.php'>";
	}
?>