<?php include("include/system_connect.php"); ?>



<?php

if (mysqli_connect_errno()) {

    printf("Connect failed: %s\n", mysqli_connect_error());

    exit();

}

$adusername=$_REQUEST['username'];

$adpassword=$_REQUEST['password'];

$var=$_REQUEST['var'];


//echo $adusername;





$sql="select status, id, type, name,cat from `admin_account_login` where `username`=? and `password`=?";

 $stmt = $mysqli->prepare($sql);
$stmt->bind_param("ss", $adusername, $adpassword);
$stmt->execute();
 $stmt->bind_result($status, $id, $type, $name,$cat);
//$row=0;
while (mysqli_stmt_fetch($stmt)) {
	    $status=$status;
		$id=$id;
		$type=$type;
		$name=$name;
		$cat=$cat;
		
		//$row++;
    }





$sql2 = $mysqli->prepare('SELECT * FROM admin_account_login where `username`=? and `password`=?');
								$sql2->bind_param("ss", $adusername, $adpassword);
								$sql2->execute();
						$sql2->store_result();
						$row=$sql2->num_rows;





if($row>0)

{

    if($status=='n')

	{

		$msg="You are blocked by Super-Admin!";

		$_SESSION['msg']=$msg;

		header("location:index.php");

	}

     else

	 {

	    
$_SESSION['username']=$adusername;
		$_SESSION['del_username']=$adusername;
		$_SESSION['admin_type']=$type;
		$_SESSION['status']=$status;
		$_SESSION['admin_id']=$id;
		$_SESSION['category']=$cat;
		
    	header("location:admin_home.php?default=home_page");
		

		

      }

}	

 

else

{	

	
	$msg="Invalid Username Or  Password!";
	$_SESSION['msg']=$msg;
   	header("location:index.php");
 }

$stmt->close();

$sql2->close();



$mysqli->close();

?>





	<html>

	<head>

	<script language="javascript">

	 function clss(){

	  history.go(-1)

	 }

	</script>

	</head>

	<body onLoad="clss()">

	

	</body>

	</html> 