<?php
include("../config/database.php");
$mobile   = $_POST['mobile'];			     
$otp      = generatePIN();
$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)
	{
		$sql = mysqli_query($cn, "update `tbl_retailer` set `otp`='".$otp."' where `mobile`='".$mobile."'"); 															
		if($sql)
		{			
			$arr = array('status'=>true, 'otp'=>$otp, 'msg'=>"OTP Send Successfully.");
			// Replace with your username
			$user = "csybus";
			// Replace with your API KEY (We have sent API KEY on activation email, also available on panel)
			$password = "SPBP7983REVA";
			// Replace with the destination mobile Number to which you want to send sms
			$msisdn = trim($sqlData['mobile']);//"9024359055";
			// Replace if you have your own Six character Sender ID, or check with our support team.
			$sid = "GhadiM";
			// Replace with client name
			$name = "Anurag Sharrma";
			// Replace if you have OTP in your template.
			$OTP = "6765R";
			// Replace with your Message content
			$msg = "your otp ".$otp." thanks you for installing Ghadi Mitra please enter this otp for login and place your order";
			 $msg = urlencode($msg);
			
			$fl = "0";
			// if you are using transaction sms api then keep gwid = 2 or if promotional then remove this parameter
			$gwid = "2";
			// For Plain Text, use "txt" ; for Unicode symbols or regional Languages like hindi/tamil/kannada use "uni"
			$type = "txt";
			
			//--------------------------------------
			//step1
			$cSession = curl_init(); 
			//step2
			curl_setopt($cSession,CURLOPT_URL,"http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user=".$user."&password=".$password."&msisdn=".$msisdn."&sid=".$sid."&msg=".$msg."&fl=0&gwid=2");
			curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
			curl_setopt($cSession,CURLOPT_HEADER, false); 
			//step3
			$result=curl_exec($cSession);
			//step4
			curl_close($cSession);
		}
		else
		{
			$arr = array('status'=>false, 'msg'=>"Some error occurred. Try Again.");			
		}
	}
	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.");
}
echo json_encode($arr);		    	
mysqli_close($cn);		
?>

