<?php
include('connection.php');

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

$q="select username,password,adminkey from administrator where username='".$username."' and password='".$password."' ";

$query=mysqli_query($connection,$q);

$row=mysqli_fetch_array($query);

if($password!=$row['password'])
{
$status="Invalid Credentials";
 header("location:index.php?status=".$status); 
       
}
else

{

session_start();
$_SESSION['loggedin']==true;
$_SESSION['adminUserName']=$row['username'];
$_SESSION['adminPassword']=$row['password'];
$_SESSION['adminkey']=$row['adminkey'];

if(isset($_POST['remember'])){
setcookie("cookadminname", $_SESSION['adminUserName'], time()+60*60*24*100, "/");
setcookie("cookadminpass", $_SESSION['adminPassword'], time()+60*60*24*100, "/");
}
header("location:products.php");
}
?>

