<?php
ob_start();
session_start();

include 'koneksi.php';
$nama_peserta = $_POST['nama_peserta'];
$sandi = $_POST['sandi'];


$login = mysqli_query($koneksi, "select * from userpeserta where nama_peserta='$nama_peserta' and sandi='$sandi'");
$cek = mysqli_num_rows($login);

if ($cek > 0) {

	$data = mysqli_fetch_assoc($login);

	if ($data['status'] == "siswa") {
		$_SESSION['nama_peserta'] = $nama_peserta;
		$_SESSION['status'] = "siswa";
		header("location:User/halamanuser.php");

	} else if ($data['status'] == "ortu") {
		$_SESSION['nama_peserta'] = $nama_peserta;
		$_SESSION['status'] = "ortu";
		header("location:Ortu/halamanortu.php");

	} else {

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

?>