<?php
//sms all members
			   $sm = "SELECT phone from users  ";
			  $acc =  mysqli_query($conn,$sm);
			
			
			if(mysqli_num_rows($acc)>0){
		   
		    $sms_array = array();
				
			while($row = mysqli_fetch_assoc($acc)){
			
		   $sms_array[] = $row["phone"];
			}}
			  $send = implode(",",$sms_array);
			  
			  $no = count($sms_array);
			  
$qryApi = mysqli_query($conn,"SELECT * FROM api_setting");
$apidata = mysqli_fetch_array($qryApi);

$apikey = $apidata['APIkey']; 
	  
		
		if(isset($_POST['btn'])){
				
		$sendto = $_POST['sendto'];
		$txt = $_POST['msg'];
        $from = $_POST['from'];

$message = utf8_encode($txt);
$aa = urlencode($message);
$sender = utf8_encode($from);
$senderid = urlencode($sender);



$baseurl ="https://vtuafrica.com.ng/portal/api/sms/?apikey=$apikey&sendto=$sendto&message=$aa&sender=$senderid";


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $baseurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$content1 = curl_exec($ch);
                                    
     $content = json_decode($content1); 
                                   
        curl_close($ch);

$APImessage = $content->description->message;

if($content->code=='101'){	
			
 echo '<div class="alert alert-success">
		<button type="button" class="close" data-dismiss="alert">×</button>
	    <strong>Message Sent.</strong> 
									</div>';

			
}
else {
    
   echo '<div class="alert alert-danger">
		<button type="button" class="close" data-dismiss="alert">×</button>
	    <strong>Error occured. '.$APImessage.'</strong> 
									</div>';
        }				

}
		
	
?>