<?php
include"../../inc/conn.php";
$username1 = mysqli_real_escape_string($connect,$_POST['username']);
$password1 = mysqli_real_escape_string($connect,$_POST['password']);
	
$username 	= str_replace("'","`",$username1);
$password 	= md5(str_replace("'","`",$password1));



	$qcek=mysqli_query($connect,"select * from tb_admin where username='$username' AND password='$password'") or die(mysqli_error());
	$hasilcek=mysqli_num_rows($qcek);
	$rcek=mysqli_fetch_array($qcek);
	if($hasilcek>0){
		session_start();
		$_SESSION['id_admin']			= $rcek['id_admin'];
		$_SESSION['status_admin']		= $rcek['status'];

		$update=mysqli_query($connect,"update tb_admin set last_login='".date('H.i - d-m-Y')."' where id_admin='".$rcek['id_admin']."'");
		echo "1";
	}else{


		echo "

			<div class='alert alert-danger alert-dismissible fade show text-center' role='alert'>
			  Username atau password salah !
			  <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
			    <span aria-hidden='true'>&times;</span>
			  </button>
			</div>


		";


		
	}


?>