<?php
include "control/activity.php";
$dd = new activity();
$mobile = $_REQUEST['mobilenumber'];

$table = "userdetails";
$condition = " where mobile='$mobile'";
$checkMobile = $dd->check($table,$condition);

if($checkMobile['status'] == "success")
{
    $remark = "Sorry Number Already exist..!!";
    print_r(json_encode(array("status" => "failed","remark" => "$remark")));
}
else{



$otp = mt_rand(111111,999999);
$curl = curl_init();
curl_setopt_array($curl, array( CURLOPT_URL => "https://otpwale.com/panel/api/bulksms/?key=92c1a134f02f62cd052c716f575605eb61561&mobile=$mobile&otp=$otp",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);

$err = curl_error($curl);
curl_close($curl);
$res = json_decode($response);
$status = $res->status;
$remark = $res->remark;


if($status == "Success"){
    print_r(json_encode(array("status" => "success","otp"=>"$otp","remark" => "Otp Sending sucessfull..!!")));
}
else{
    print_r(json_encode(array("status" => "failed","remark" => "$remark")));
}

}
?>