<?php
include("../config/database.php");
$mobile = $_POST['mobile'];			     
$otp    = trim($_POST['otp']);
$sql    = mysqli_query($cn, "select * from `tbl_retailer` where `mobile`='".$mobile."'");
if(mysqli_num_rows($sql)>0)
{
	$sqlData = mysqli_fetch_array($sql); 															
	if($sqlData['status']==1)
	{
		if($sqlData['otp']==$otp)
		{			
			$name =""; $address = ""; $pincode = "";
			if(!empty($sqlData['name'])){$name = $sqlData['name'];}
			if(!empty($sqlData['address'])){$address = $sqlData['address'];}
			if(!empty($sqlData['pincode'])){$pincode = $sqlData['pincode'];}
			$arr = array('status'=>true, 'msg'=>"Login Successfully.", 'shop_id'=>$sqlData['id'], 'name'=>$name, 'shop_name'=>$sqlData['shop_name'], 'mobile'=>$sqlData['mobile'], 'state'=>$sqlData['state'], 'district'=>$sqlData['district'], 'town'=>$sqlData['sale_district'], 'address'=>$address, 'pincode'=>$pincode, 'ds_name'=>dsName($sqlData['ds_code']), 'beat'=>$sqlData['beat']);		
		}
		else
		{
			$arr = array('status'=>false, 'msg'=>"Wrong OTP.");			
		}
	}
	else
	{
		$arr = array('status'=>false, 'msg'=>"Your Registration Under Review. Contact To Service Provider.");			
	}
}
else
{
	$arr = array('status'=>false,'msg'=>"This mobile does't Registered. Sign up First.");
}
echo json_encode($arr);		    	
mysqli_close($cn);		
?>

