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++

}

}

?>
Re: how to send automated sms via php 80 80
Member Avatar

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!!

The code you provide doesn't do that. It's best to find a code that has API SMS.

Try these:

http://www.catswhocode.com/blog/sending-sms-with-php-and-textmagic-an-a-to-z-guide

http://www.learncomputer.com/text-messages-with-php/

http://gonzalo123.com/2011/03/21/howto-sendread-smss-using-a-gsm-modem-at-commands-and-php/

Re: how to send automated sms via php 80 80

Hi kwamephp!

For sending a sms expriation reminder i suggest to you to use a php script to create a code.
Here's an example for sending text messages in php: http://www.ozekisms.com/index.php?owpn=204&info=php_sms_example

I hope i can help you!

Re: how to send automated sms via php 80 80

For windows, I'd recomend that you use OzekiSMS gateway. Follow this link to learn more.

For linux, you can use Kannel. Find the link here.

Regards.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.