<?php

include "connection.php";



if(isset($_POST['login'])){

	extract($_POST);



    $query   = "select * from adminuser where email = '$email' and password ='$password' and status = 'admin'";

	

	$result  = mysqli_query($con,$query);

	$num_row = mysqli_num_rows($result);



	if( $num_row > 0){

		$row    = mysqli_fetch_assoc($result);
		$id = $row['id'];
		$date = date("Y-m-d H:i:s");
		$ip   =  $ip =  $_SERVER['REMOTE_ADDR'];
		$query = "INSERT INTO `login_record` VALUES ('','$id2','$ip','$date',' ')";
		$result= mysqli_query($con,$query);

	    $_SESSION['user']  = $row;

	    header("location:index.php");

	}else{

		header("location:login.php?msg=error");

	}

}elseif(isset($_GET['logout'])){



		session_destroy();

		header("location:login.php");

}



?>