<?php
session_start();

include 'koneksi.php';
$username = $_POST['username'];
$password = $_POST['password'];

$login = mysqli_query($koneksi, "select * from user where username='$username' and password='$password'");
$cek = mysqli_num_rows($login);

if ($cek > 0) {

	$data = mysqli_fetch_assoc($login);

	if ($data['status'] == "admin") {

		$_SESSION['username'] = $username;
		$_SESSION['status'] = "admin";
		header("location:Admin/halaman_admin.php");

	} else if ($data['status'] == "coach") {
		$_SESSION['username'] = $username;
		$_SESSION['status'] = "coach";
		header("location:Coach/halaman_coach.php");

	} else {

		header("location:loginpageadmin.php?pesan=gagal");
	}
} else {
	header("location:loginpageadmin.php?pesan=gagal");
}

?>