<?php
session_start();
?>

<?php
require_once 'fungsi/koneksi.php';
if(isset($_POST['submit'])){
	$username = $_POST['username'];
	$password = $_POST['password'];

	$query = "SELECT iduser,username,admin,fullname FROM user WHERE username='$username' AND password=md5('$password')";
	$hasil = mysqli_query($kon, $query);
	if(mysqli_num_rows($hasil) > 0){
		list($iduser,$username,$admin,$fullname) = mysqli_fetch_array($hasil);

		//session_start()
		$_SESSION['iduser'] = $iduser;
		$_SESSION['username'] = $username;
		$_SESSION['admin'] = $admin;
		$_SESSION['fullname'] = $fullname;

		echo "<script>alert('Selamat Datang');document.location='mainform.php?halaman=home'</script>";
	}else {
		echo "<script>alert('Username Atau Password Salah !');document.location='index.php'</script>";
	}
}
?>

<!DOCTYPE html>
<html>
<head>
	<title>SPP : Syamsul 'Ulum</title>
	<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<form method="post" action="">
	<div id="formlogin">
	<h2><strong>APLIKASI<br>PEMBAYARAN SPP <div class="rb">SMK YASPI SYAMSUL 'ULUM<br>KOTA SUKABUMI</div></strong></h2>
	<input type="text" name="username" class="control" placeholder="Username" required>
	<input type="password" name="password" class="control" placeholder="Password" required>
	<input type="submit" class="btn-login" name="submit" value="LOGIN">
</form>
</div>
</body>
</html>