I'm trying to create an automated sms expiration reminder but i'm kind of stuck and don't know where i'm going wrong. Can anyone help plssssssss!!
<?
require('file/connection.php');
$resul = mysql_query("SELECT `firstname` , `phonenumber` , `dob`
FROM `members`
WHERE DATEDIFF(`dob`,CURDATE())=7 ")or die(mysql_error());
$num = mysql_numrows($resul);
mysql_close();
$i=0;
while($i < $num)
{
$firstname=mysql_result($resul,$i,"firstname")
$phonenumber=mysql_result($resul,$i,"phonenumber");
$expiry=mysql_result($resul,$i,"dob");
$expiry =date("d-m-Y", strtotime($expiry));
if($resul == TRUE){
// this function handles the sending of sms using the api generated
function send_sms($message,$phone,$sender_id){
$key= "0eea755d253045b180ce";
$message=urlencode($message);
$url="http://bulk.mnotification.com/smsapi?key=".$key."&to=".$phone."&msg=".$message."&sender_id=".$sender_id."";
$result=file_get_contents($url);
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,$url);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
print $buffer;
if($result=="1000"){
echo "Message sent";
}elseif($result=="1002"){
echo "Message not sent";
}elseif(($result=="1003")){
echo "You don't have enough balance";
}elseif(($result=="1004")){
echo "Invalid API Key";
}
}
//now you can call this function under a button say..
if($resul == TRUE){
$message="Hello ".$firstname." your insurance is 7 days to expiration and will expire on". $dob . ".Don't forget to renew your account. Thank You!";
//the message can be from a form field
$phone = $phonenumber; // the phone number can be from a form field
$sender_id="ELTON"; // the sender id can be from a form field
send_sms($message,$phone,$sender_id);
i++
}
}
?>