<?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 user_master WHERE emailId='$username'";
   	 
      	$myquery=$conn->query($sql);
   	$mydara= $myquery->fetchAll()  ;
   	
   	$rows_found = $myquery->rowCount();
   	 
   	if($rows_found==0){
   		$_SESSION[ADD_TAG.'_unvalidate_user']=12;
   		$_SESSION[ADD_TAG.'_tologusername_user']='';
   		
   		$pagename='Admin Login ';
   				$parameter='suspicious Login for Admin ';
   				$alertdisplay=' For Email ID '.$email_id  ;
   				
   		
   		header('Location: ../login-role/user');
   		}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_user']='';
   				unset($_SESSION[ADD_TAG.'_unvalidate_user']);
                       $_SESSION[ADD_TAG.'_UserId_user']=$userId;
   				   $_SESSION[ADD_TAG.'_FirstName_user']=$first_name;
   				   $_SESSION[ADD_TAG.'_EmailID_user']=$email_id;
   				   $_SESSION[ADD_TAG.'_MoBilENo_user']=$mobile_no;
   				
   					$pagename='user Login ';
   					$parameter='Login Successful for user ';
   					$alertdisplay=' For Email ID '.$email_id  ;
   					
   					header('Location: ./../validation/valproveuser.php');
   					
   			}else{
   			 
   				$_SESSION[ADD_TAG.'_unvalidate_user']=14;
   				$_SESSION[ADD_TAG.'_tologusername_user']=$username;
   			
   				$pagename='Admin Login ';
   				$parameter='Invalid Password';
   				$alertdisplay=' For Email ID '.$username .' Password used '.$password_new;
   				header('Location: ../login-role/user');
               	
   				}
   			}
   			
   
   	 
   ?>