<?php
include ("config.php");
session_destroy();
  $mobile=$_POST['value'];
 $otp=rand(1000,10000);
 $sql4="SELECT * FROM loginuser WHERE mobile='$mobile'";
$select5=mysqli_query($com,$sql4)or die(mysqli_error($com));
$count_row=mysqli_num_rows($select5);
if($count_row != '0')
{
    session_start();
    unset($_SESSION["signup_mobile"]);
	unset($_SESSION["signup_otp"]);
	
	session_destroy();
	
	session_start();
	
  $_SESSION["signup_mobile"] = $mobile;
  $_SESSION["signup_otp"] = $otp; 
  
  $fields = array(
    "sender_id" => "TXTIND",
    "message" => "  verification code is $otp ",
    "language" => "english",
    "route" => "v3",
    "numbers" => $mobile,
    "flash" => "0"
);

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://www.fast2sms.com/dev/bulkV2",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode($fields),
  CURLOPT_HTTPHEADER => array(
    "authorization: WgwtcMhfDpU4FaP52VBl1eJxoRmzG0ybY98E3j7SiCn6LQqZdTjc9smqaQDKC3N2M5iltPEB6AFkWYhp",
    "accept: */*",
    "cache-control: no-cache",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);


 echo $otp;
}else{
   echo $count_row; 
}

?>