<?php

include_once "config.php";

$json_smsdata=[];

if ($_POST['selectedcheckbox']) {

    //$class_name = $_POST['classname'];

    $smstxt=$_POST['smstext'];


    $st_idnumber = mysqli_real_escape_string($link,$_POST['selectedcheckbox']);


    

    $sql= "SELECT st_id as st_id, st_name as st_name, father_mobile as st_mobile,access_code as idAcess
   
    FROM 
    student_list_ju
    WHERE st_id IN ( $st_idnumber)
    
    ";

$result = mysqli_query($link,$sql);
$nCount=0;



while($row = mysqli_fetch_assoc($result)){

    $nCount++;
  $idnumber=$number=$row ['st_id'];
    $number=$row ['st_mobile'];
$accesscode=$row ['idAcess'];
$studentname=$row ['st_name'];

if ($smstxt!=null){
   //$sms=$smstxt. "\nYour Name: ".$studentname."\nYour Id: ".$idnumber. "\nAccess Code: ".$accesscode."\nJoin Live Class: www.liveclass.bpatcsc.org\nbpatcsc"; 
   $sms=$smstxt. "\nYour Name: ".$studentname."\nYour Id: ".$idnumber. "\nAccess Code: ".$accesscode."\nOnline Result: https://easyresult.easytechsolution.org\nbpatcsc";
}else{
//$sms="Your Name: ".$studentname."\nYour Id: ".$idnumber. "\nAccess Code: ".$accesscode."\nJoin Live Class: www.liveclass.bpatcsc.org\nbpatcsc"; 
$sms="Your Name: ".$studentname."\nYour Id: ".$idnumber. "\nAccess Code: ".$accesscode."\nOnline Result: https://easyresult.easytechsolution.org\nbpatcsc";    
}


$message = rawurlencode($sms);
  
                    $json_smsdata[]= ['to'=>$number,'message'=>$message];
                                  
  
}
  
$smsdata = json_encode($json_smsdata);


        
	
// // আমরা $to তে সব নাম্বার কমা সেপারেট করা অবস্থায় পেয়েছি এবার এসএমএস প্রেরন করুন
$token = "d28c64966d30bb80787a063d678a85bc";
$smsdata = $smsdata;

//$url = "http://api.greenweb.com.bd/api2.php";
$url = "http://api.greenweb.com.bd/api.php";


$data= array(
'smsdata'=>"$smsdata",
'token'=>"$token"
); // Add parameters in key value
$ch = curl_init(); // Initialize cURL
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$smsresult = curl_exec($ch);

//Result
echo $smsresult;

//Error Display
echo curl_error($ch);  
 






}









?>



