<?php

session_start();

include  "../koneksi/koneksi.php";

$username = $_POST['username'];
$password = base64_encode($_POST['password']);
// query untuk mendapatkan record dari username
$query = "SELECT * FROM user WHERE username = '$username'";
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
// cek kesesuaian password
if ($password == $data['password'])
{ 
    // menyimpan username dan level ke dalam session
    $_SESSION['username'] = $data['username'];
	$_SESSION['nama']     = $data['nama'];
	$_SESSION['id']     = $data['id'];
	$_SESSION['email']     = $data['email'];
	$_SESSION['hp']     = $data['hp'];
	$_SESSION['end_date']     = $data['end_date'];
    header('location:../index.php');
	
}
else {
header('location: ../login.php?error='.base64_encode('Maaf Username dan Password Salah'));
        exit();
}
?>

