<?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';

date_default_timezone_set("Asia/Karachi");

$today=date("Y-m-d");
echo "<h1 align=center> Select Student 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["mess"];
			$today=date("Y-m-d");
			$sqlp14 = "select * from admission where id='$del_id' and user_id='$userid'";
 							$finishstock=mysql_query($sqlp14) or die("Error : " . mysql_error());
   							$app1=mysql_fetch_array($finishstock);
   							$std_rollno=$app1["std_rollno"];
							$std_name=$app1["std_name"];
							$class_name=$app1["class_name"];
							$father_name=$app1["father_name"];
							$cell_1=$app1["cell_1"];
			
							$cell_2=$app1["cell_2"];
							
							
							$type = "xml"; 
$id = "rchalainsch"; 
$pass = "alain786"; 
$lang = "English"; 
$mask = "AlainSchool";   
// Data for text message 
$to = $cell_1; 
$message =   $std_name .  "::" . $mess; 
$message1 =   $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); 
							
							$sql16 = "Insert into notice (id,date,month_name,sname,notice,total,user_id,cell_1) values (null,'$today','$month_name','$std_name','$message1','1','$userid','$to')";
mysql_query($sql16) or die("Error : " . mysql_error());
							
							
							
						echo "<table border=1 width=100% align=center bgcolor=#FFFF66>";	
			  echo "<tr>";
  echo "<td width=30%>" .$std_name. "</td>";
   echo "<td width=10%>" .$std_rollno. "</td>";
    echo "<td width=30%>" .$father_name. "</td>";
	 echo "<td width=10%>" .$class_name. "</td>";
	   echo "<td width=10%>" .$cell_1. "</td>";
	    echo "<td width=10%>" .$mess. "</td>";
		
  echo "</tr>";	
  echo "</table>";		
 
		}
			
	}
?>
