<?php 

session_start();
include("db_config.php"); 
     
if($_SERVER['REQUEST_METHOD']=='POST'){	
	//var_dump($_POST);
		$mobile_no = $_POST['mobile_no'];
		$type = $_POST['type'];
		    $username='jhwebs1';
			$mobile_no= $_POST['mobile_no'];
			$from='JHWEBS';
			$password='123456';
			$otp = rand(100000, 999999);
            $_SESSION['otp']=$otp;
             $data=$_SESSION['otp'];
		    $sms_content = "Welcome to MMart: Your verification code is " .$otp;
		    $msg = urlencode($sms_content);

		    $url = "http://smslogin.mobi/spanelv2/api.php?username=".$username."&password=".$password."&to=".$mobile_no."&from=".$from."&message=".($msg);
		
		    $response1 = file($url);
		    if($type==="1"){
			$json = array("status" => 1,"otp" => $otp, "msg" => "Resend OTP Successful!");
        } else if($type==="2") {
        	$json = array("status" => 2,"otp" => $otp, "msg" => "Resend OTP Successful!");
        } else {
        	$json = array("status" =>0, "msg" => "Something Wrong!");
        	//$response['status']=0;
        }
	
		echo json_encode($json);
		//echo json_encode($response);
		mysqli_close($conn);
	}
	
?>