<?php


if(isset($_POST['phone']) && isset($_POST['msg'])){
    


//Your authentication key
$authKey = "303492ABclRI8935dd50413";

//Multiple mobiles numbers separated by comma
$mobileNumber = $_POST['phone'];

//Sender ID,While using route4 sender id should be 6 characters long.
$senderId = "GRNDSE";

//Your message to send, Add URL encoding here.
$message = urlencode($_POST['msg']);

//Define route 
$route = "default";
//Prepare you post parameters
$postData = array(
    'authkey' => $authKey,
    'mobiles' => $mobileNumber,
    'message' => $message,
    'sender' => $senderId,
    'route' => $route
);

//API URL
$url="http://api.msg91.com/api/sendhttp.php";

// init the resource
$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $postData
    //,CURLOPT_FOLLOWLOCATION => true
));


//Ignore SSL certificate verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);


//get response
$output = curl_exec($ch);

//Print error if any
if(curl_errno($ch))
{
    echo 'error:' . curl_error($ch);
}

curl_close($ch);

 if($output != NULL);
  echo "message sent!";
}



?>

<form action="" method="post">
    <h3>SMS sent in PHP</h3>
    
    Multiple mobiles numbers separated by comma<br>
    <input type="text" name="phone" placeholder="Enter mobile number"><br><br>
    
    <textarea name="msg" placeholder="Type your message"></textarea><br><br>
    <input type="submit" value="Send">
</form>