Viewing file: stud_action.php (3.12 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
require 'connection.php';
session_start();
//$user_id = $_SESSION['user_id'];
$teacher_id = $_SESSION['user_id'];
$msg = $_REQUEST['message'];
$msgtype='signin';
$username = "srishti";
/* Your Password */
$password = "9895345468";
/* Multiple mobiles numbers separated by comma */
$mobileNumber = '7736695330';
/* Sender ID,While using route4 sender id should be 6 characters long. */
$senderId = "SRICAM";
$message = urlencode($msg);
// $message = urlencode($rndno);
/* Define route */
$route = "2";
/* Prepare you post parameters */
$postData = array(
'uname' => $username,
'pwd' => $password,
'mobiles' => $mobileNumber,
'message' => $message,
'sender' => $senderId,
'route' => $route
);
$DltTemplateId='';
if($msgtype=='signup'){
$DltTemplateId='1207161530126047850';
}else if($msgtype=='signin') {
$DltTemplateId='1207161530117680218';
}
/* API URL */
//$url = "http://alvosms.in/api/v1/send?token=ivku4o2r6gjdq98bm3aesl50pyz7h1&numbers=" . $mobileNumber . "&route=" . $route . "&message=" . $message . "&sender=" . $senderId;
$url="http://alvosms.in/api/v1/send?token=ivku4o2r6gjdq98bm3aesl50pyz7h1&numbers=".$mobileNumber."&route=".$route."&message=".$message."&sender=".$senderId."&template-id=".$DltTemplateId;
// echo $url;die();
/* init the resource */
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
// CURLOPT_POST => true,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
// CURLOPT_POSTFIELDS => $postData
));
/* get response */
$output = curl_exec($ch);
//print_r($output);
/* Print error if any */
if (curl_errno($ch)) {
echo 'error:' . curl_error($ch);
}
curl_close($ch);
// echo 'OTP Sent Successfully !';
// die();
//return $rndno;
if($teacher_id==1){
$sql="select * from enrolldetails ";
$result=$con->query($sql);
$count=$result->num_rows;
if($count>0){
while($row=$result->fetch_assoc()){
$id=$row['user_id'];
$staff=$row['staff'];
if(!empty($staff)){
$ins = "INSERT INTO notifications (`user_id`,teacher_id,message,status) VALUES ('$id','$teacher_id','$msg','0')";
$res=$con->query($ins);
}
}
header("Location:view_students.php?id=send");
}
else{
header("Location:view_students.php?id=failed");
//echo $ins;
}
}
else{
$sql="select * from enrolldetails where staff=$teacher_id ";
$result=$con->query($sql);
$count=$result->num_rows;
if($count>0){
while($row=$result->fetch_assoc()){
$id=$row['user_id'];
$ins = "INSERT INTO notifications (`user_id`,teacher_id,message,status) VALUES ('$id','$teacher_id','$msg','0')";
$res=$con->query($ins);
}
header("Location:view_students.php?id=send");
}
else{
header("Location:view_students.php?id=failed");
//echo $ins;
}
}
?>
|