<?php
session_start();
include_once('connection.php');

$username	= $_POST['username'];
$password	= $_POST['password'];

//$username	= "shantiranjan.web@gmail.com";
//$password	= "admin@123";
if($username == ''){
	echo 'Please Enter Email<br>';
}
if(!filter_var($username, FILTER_VALIDATE_EMAIL)) 
{
	echo "Invalid email format<br>";
}else if($password == ''){
	echo 'Please Enter Password';
}else{
	
	//$password	= md5($password);	
	$result = mysqli_query($conn,"SELECT * FROM `administrator` WHERE `username` = '$username' AND `password` = '$password' AND `status` = '1'");
	$row = mysqli_fetch_array($result);
	$userId = $row['id'];

	
	if($userId > 0){
		$expire = (time()+60*60*24*365);
		setcookie("adminLogAdmin", $username, $expire, "/", "salesready.in");
		echo "success";
	}else{
		echo "Invalid login data";
	}
}
