mutago
02-15-2014, 07:00 PM
1: I used this code below to send sms and its working but the problem is that it was the form action that was sending it instead of curl and as such i couldn't be able to print a message eg sms successful or sms sending fails based on the values given to me by the sms resellers
eg ok means the message was succesful
2904 means the message could not be sent
form action = "http://www.sms_site.com/smsapi.php"
form action sends the sms instead of
$Curl_Session = curl_init('http://www.sms_site/smsapi.php');
2: How do i print that sms messages were sent or not based on the assigned values above
any help
below is the working code so far
<?php
echo' <table width="100%" border="0">
<tr>
<td valign="top"><div id="estblshmt-form">
<div class="head"><font color=green size=5>Send Bulk SMS</font></div>
';
//echo '<form name=form1 method=get action="http://www.sms_site.com/smsapi.php">';
echo '<form name=form1 method=POST >';
echo '<label>Sender ID:</label>';
echo '<input id="sender" name="sender"><br><br>';
echo '<label>Reciever:</label>';
echo '<input id="recipient" name="recipient"><br><br>';
echo '<label>Message:</label>';
echo '<textarea name="message" id="message"rows="4" cols="50"></textarea><br>';
//echo '<input id="message" name="message"><br><br>';
//echo '<input type=submit name=Submit value=Register>';
echo'<input type="submit" name="add_subcat" id="add_subcat" value="Send SMS Now!" class="btn btn-info btn-small">';
echo '</form>';
echo '</td>';
echo '</tr>';
echo '</table>';
?>
<?php
$username = (isset($_POST['username']) ) ? $_POST['username'] : '';
$password = (isset($_POST['password']) ) ? $_POST['password'] : '';
$sender = (isset($_POST['sender']) ) ? $_POST['sender'] : '';
$recipient = (isset($_POST['recipient']) ) ? $_POST['recipient'] : '';
$message = (isset($_POST['message']) ) ? $_POST['message'] : '';
$Curl_Session = curl_init('http://www.sms_site.com/smsapi.php');
curl_setopt ($Curl_Session, CURLOPT_POST, 1);
curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "username=$username&password=$password&sender=$sender&recipient=$recipient&message=$message");
curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($Curl_Session, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($Curl_Session);
//$a1=array("ok","2904","2905");
if ($result == 'ok'){
echo 'message sent';
}
elseif ($result == '2904'){
echo 'message sending failed';
}else{
echo '';
}
Print($result);
curl_close ($Curl_Session);
?>
eg ok means the message was succesful
2904 means the message could not be sent
form action = "http://www.sms_site.com/smsapi.php"
form action sends the sms instead of
$Curl_Session = curl_init('http://www.sms_site/smsapi.php');
2: How do i print that sms messages were sent or not based on the assigned values above
any help
below is the working code so far
<?php
echo' <table width="100%" border="0">
<tr>
<td valign="top"><div id="estblshmt-form">
<div class="head"><font color=green size=5>Send Bulk SMS</font></div>
';
//echo '<form name=form1 method=get action="http://www.sms_site.com/smsapi.php">';
echo '<form name=form1 method=POST >';
echo '<label>Sender ID:</label>';
echo '<input id="sender" name="sender"><br><br>';
echo '<label>Reciever:</label>';
echo '<input id="recipient" name="recipient"><br><br>';
echo '<label>Message:</label>';
echo '<textarea name="message" id="message"rows="4" cols="50"></textarea><br>';
//echo '<input id="message" name="message"><br><br>';
//echo '<input type=submit name=Submit value=Register>';
echo'<input type="submit" name="add_subcat" id="add_subcat" value="Send SMS Now!" class="btn btn-info btn-small">';
echo '</form>';
echo '</td>';
echo '</tr>';
echo '</table>';
?>
<?php
$username = (isset($_POST['username']) ) ? $_POST['username'] : '';
$password = (isset($_POST['password']) ) ? $_POST['password'] : '';
$sender = (isset($_POST['sender']) ) ? $_POST['sender'] : '';
$recipient = (isset($_POST['recipient']) ) ? $_POST['recipient'] : '';
$message = (isset($_POST['message']) ) ? $_POST['message'] : '';
$Curl_Session = curl_init('http://www.sms_site.com/smsapi.php');
curl_setopt ($Curl_Session, CURLOPT_POST, 1);
curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "username=$username&password=$password&sender=$sender&recipient=$recipient&message=$message");
curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($Curl_Session, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($Curl_Session);
//$a1=array("ok","2904","2905");
if ($result == 'ok'){
echo 'message sent';
}
elseif ($result == '2904'){
echo 'message sending failed';
}else{
echo '';
}
Print($result);
curl_close ($Curl_Session);
?>