<?php 
ob_start();
session_start();
include("config.php");

$admin=mysqli_real_escape_string($con,$_POST['email']);
$password=mysqli_real_escape_string($con,$_POST['spass']);

if(isset($_POST['login'])=="login")
{
    
    
    
	$sql="select * from `admin` where `email`='".$admin."' and `password`='".md5($password)."'";
	//print_r($sql);exit;
	$result=mysqli_query($con,$sql);
	$num=mysqli_num_rows($result);
	$line=mysqli_fetch_assoc($result);
	if($num>=1)
	{
		
		$userid=$line['id'] ;
		$_SESSION['Adminid']=$userid;
		$_SESSION['admin_name']=$line['admin_name'];
		$_SESSION['role_id']=$line['role'];
		
		
		header("location:index.php");
		exit;
	}
	else
	{
		header("location:login.php?err=ture");
		exit;
	}
}
else
{
	header("location:login.php?err=ture");
	exit;
}
?>