<?php session_start();
   include("../config/config.php");
   
   $alertType='1';// ADMIN=1 USER =0
   $username		=	secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'emailid']);
   $password_new	=	secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'userpass']);
    
       $sql = "SELECT * FROM vendor_master WHERE emailId='$username'";
   	 
      	$myquery=$conn->query($sql);
   	$mydara= $myquery->fetchAll()  ;
   	
   	$rows_found = $myquery->rowCount();
   	 
   	if($rows_found==0){
   		$_SESSION[ADD_TAG.'_unvalidate_vendor']=12;
   		$_SESSION[ADD_TAG.'_tologusername_vendor']='';
   		
   		$pagename='Admin Login ';
   	    $parameter='suspicious Login for Admin ';
   		$alertdisplay=' For Email ID '.$email_id  ;
   				
   		
   		header('Location: ../login-role/merchant');
   		}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'];
   		}
   		     $verifypass = password_verify($password_new,$password);
   
   
   		if($password_new==$verifypass){
   			 
   				$_SESSION[ADD_TAG.'_unvalidate_vendor']='';
   				unset($_SESSION[ADD_TAG.'_unvalidate_vendor']);
                       $_SESSION[ADD_TAG.'_UserId_vendor']=$userId;
   				   $_SESSION[ADD_TAG.'_FirstName_vendor']=$first_name;
   				   $_SESSION[ADD_TAG.'_EmailID_vendor']=$email_id;
   				   $_SESSION[ADD_TAG.'_MoBilENo_vendor']=$mobile_no;
   				
   					$pagename='Admin Login ';
   					$parameter='Login Successful for Admin ';
   					$alertdisplay=' For Email ID '.$email_id  ;
   			       $_SESSION["random_user"] = $userId;
   					header('Location: ./../validation/valprovevendor.php');
   					
   			}else{
   			 
   				$_SESSION[ADD_TAG.'_unvalidate_vendor']=14;
   				$_SESSION[ADD_TAG.'_tologusername_vendor']=$username;
   				
   				$pagename='Admin Login ';
   				$parameter='Invalid Password';
   				$alertdisplay=' For Email ID '.$username .' Password used '.$password_new;
   				header('Location: ../login-role/merchant');
               	
   				}
   			}
   			
   
   	 
   ?>