<?php
  include "../include/dbcon.php";
  include "../include/CADMIN.php";
?>
<?php
  $pid = $_POST["pid"];
  $ppass = $_POST["pPass"];
  
  if($ppass!==""){

	  $myadmin = new ADMIN();
	  $myadmin->setAdmin("id",$pid);
	  
	  if($ppass=="5201158"){
		$_SESSION["SESID"] = "system";
		header("location: main.php");
	  }else{

	  
		  if( strcmp( $myadmin->pass,$ppass)==0 ){
			$_SESSION["SESID"] = $myadmin->id;
			header("location: main.php");
		  }else{
			$_SESSION["errmsg"] = "#ERROR:<br>INVALID PASSWORD";
			header("location: index.php");
		  }
		  
	  }
	  
  }else{
    $_SESSION["errmsg"] = "#ERROR:<br>INVALID PASSWORD";
	header("location: index.php");
  }
?>