<?php session_start();
   include("../config/config.php");
   include("./../validation/validate_vendorlogin.php");
   
   
   $alertType='1';// ADMIN=1 USER =0
   $password_old		=	secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'old']);
   $password_new	=	secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'new']);
   $userids	=	secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'userid']);
     $user_id=$_SESSION[ADD_TAG.'_UserId_vendor'];
    
       $sql = "SELECT * FROM vendor_master WHERE rowId='$user_id'";
   	 
      	$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']='';
   		
   		$pagename='Admin Login ';
   				$parameter='suspicious Login for Admin ';
   				$alertdisplay=' For Email ID '.$email_id  ;
   				
   			
   		
   		header('Location: ./../login');
   		}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_old,$password);
   
   
   		if($password_old==$verifypass){
   			$hash = password_hash($password_new,PASSWORD_DEFAULT);
   			 
   			   $sqls = "UPDATE vendor_master SET userpass='$hash' WHERE rowId='$userids'";
   	 
      	$myquerys=$conn->query($sqls);
      	$_SESSION[ADD_TAG.'_Tab_id']=2;
      	header('Location: ../merchant-user/'.$userids);
               	
   				
   					
   			}else{
   			 
   	    $_SESSION[ADD_TAG.'_unvalidate_vendor']=16;
   		$_SESSION[ADD_TAG.'_tologusername']='';
   		
   		$pagename='Admin Login ';
   				$parameter='suspicious Login for Admin ';
   				$alertdisplay=' For Email ID '.$email_id  ;
   					$_SESSION[ADD_TAG.'_Tab_id']=2;
   				header('Location: ../merchant-user/'.$userids);
               	
   				}
   			}
   			
   
   	 
   ?>