<?php 
session_start();
//mysql_connect("localhost","root","vertrigo") or die("Error Connecting Server");
//mysql_select_db("sm") or die("Error Opening Database");
include 'dbc.php';


$today=date("Y-m-d");
echo "<h1 align=center> Select Teacher Data Report </h1>";
if($_POST['delete']) // from button name="delete"
	{
		$checkbox = $_POST['checkbox']; //from name="checkbox[]"
		$countCheck = count($_POST['checkbox']);
		
		for($i=0;$i<$countCheck;$i++)
		{
			$del_id  = $checkbox[$i];
			$userid=$_SESSION["userid"];
			$mess=$_POST["remarks"];
			$today=date("Y-m-d");
			$sql = "SELECT * FROM teacher where id = '$del_id' and user_id = '$username'";
$result=$conn->query($sql);
$app1 = $result->fetch_assoc();
   							
							$std_name=$app1["std_name"];
							
							$cell_1=$app1["cell_1"];
							
							
							$type = "xml"; 
$id = "rchalliedcamp"; 
$pass = "tobatek786786"; 
$lang = "English"; 
$mask = "ALLIED-TTS";  
// Data for text message 
$to = "92" . $cell_1; 
$message =   $std_name .  "::" . $mess; 
$message = urlencode($message);   
// Prepare data for POST request 
$data = "id=".$id."&pass=".$pass."&msg=".$message."&to=".$to."&lang=".$lang."&mask=".$mask."&type=".$type;   
// Send the POST request with cURL 
$ch = curl_init('http://www.outreach.pk/api/sendsms.php/sendsms/url'); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$result = curl_exec($ch); 
//This is the result from Outreach 

curl_close($ch); 
							
							
							
							
			
  $sql = "Insert into sms (id,date,std_rollno,std_name,class_name,cell_1,mesg,user_id) values (null,'$today','$std_rollno','$std_name','$class_name','$cell_1','$message','$userid')";
mysql_query($sql) or die("Error : " . mysql_error());


		}
			
	}
	echo "Message Send";
?>
<a href="Individual_Sms.php">Back</a>