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

$alertType='1';// ADMIN=1 USER =0
$username		=	secureSuperGlobalPOST($_REQUEST['logUserName']);
$password_new	=	secureSuperGlobalPOST($_REQUEST['logUserPassword']);
 
    $sql = "SELECT * FROM admin_master WHERE emailid='$username'";
	 
   	$myquery=$conn->query($sql);
	$mydara= $myquery->fetchAll()  ;
	
	$rows_found = $myquery->rowCount();
	 
	if($rows_found==0){
		$_SESSION[ADD_TAG.'_unvalidate']=12;
		$_SESSION[ADD_TAG.'_tologusername']='';
		
		$pagename='Admin Login ';
				$parameter='suspicious Login for Admin ';
				$alertdisplay=' For Email ID '.$email_id  ;
				
		
		header('Location: ../login.php');
		}else{
			 
			foreach( $mydara as $row ) {
				$userId		= $row['rowId'];
				$first_name	= $row['first_name'];
				$email_id	= $row['emailid'];
				$mobile_no	= $row['mobile_no'];
				$password= $row['userpass'];
					$company_name	= $row['company_name'];
			}
		     $verifypass=password_verify($password_new,$password);


		if($password_new==$verifypass){
			 
				$_SESSION[ADD_TAG.'_unvalidate']='';
				unset($_SESSION[ADD_TAG.'_unvalidate']);
                    $_SESSION[ADD_TAG.'_UserId']=$userId;
				   $_SESSION[ADD_TAG.'_FirstName']=$first_name;
				   $_SESSION[ADD_TAG.'_EmailID']=$email_id;
				   $_SESSION[ADD_TAG.'_MoBilENo']=$mobile_no;
				    $_SESSION[ADD_TAG.'_Company']=$company_name;
				
					$pagename='Admin Login ';
					$parameter='Login Successful for Admin ';
					$alertdisplay=' For Email ID '.$email_id  ;
				
					header('Location: ./valapprove.php');
					
			}else{
			 
				$_SESSION[ADD_TAG.'_unvalidate']=14;
				$_SESSION[ADD_TAG.'_tologusername']=$username;
				
				$pagename='Admin Login ';
				$parameter='Invalid Password';
				$alertdisplay=' For Email ID '.$username .' Password used '.$password_new;
				header('Location: ../login.php');
            	
				}
			}
			

	 
?>		