<?php 
// menghubungkan dengan koneksi
include 'koneksi.php';

// menangkap data yang dikirim dari form
$username = $_POST['username'];
$password = md5($_POST['password']);

$login = mysqli_query($koneksi, "SELECT * FROM guru WHERE guru_username='$username' AND guru_password='$password'");
$cek = mysqli_num_rows($login);

if($cek > 0){
	session_start();
	$data = mysqli_fetch_assoc($login);
	$_SESSION['id'] = $data['guru_id'];
	$_SESSION['nama'] = $data['guru_nama'];
	$_SESSION['username'] = $data['guru_username'];
	$_SESSION['level'] = "guru";

	header("location:guru/");
}else{
	header("location:admin.php?alert=gagal");
}
