<?php
session_start();
include "connect.php";
$passwd=md5($_POST["password"]);
$login = mysql_query("select * from tb_user where username=\"".$_POST["username"]."\" and password=\"$passwd\"");
$rowcount = mysql_num_rows($login);

$data=mysql_fetch_array($login);

if ($rowcount >= 1) {
	//Deklarasi Session (username dan role)
	$_SESSION["username"] = $_POST["username"];
	$_SESSION["role"] 	  = $data["role"];

	header("Location: main.php");
}
else
{
	header("Location:index.php?loginError");
}
?>