Hi All,
I have a PHP code for Sending http post from cURL. it work fine but i have a trouble that when i am send any data from loop it display me only first string the remaining string it not print.
I am Use this Code.
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Send Group SMS to Your all Clients.</title>
<LINK
href="styles/changepw.css"
type=text/css rel=stylesheet>
<LINK rel="stylesheet" href="styles/ui.tabs.css" type="text/css" media="print, projection, screen">
<SCRIPT src="js/jquery-1.2.6.js" type="text/javascript"></SCRIPT>
<SCRIPT src="js/ui.core.js" type="text/javascript"></SCRIPT>
<SCRIPT src="js/ui.tabs.js" type="text/javascript"></SCRIPT>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="100%"><h2>Send Group SMS</h2>
<p align="justify"><font size="2">To Send SMS on any Desired Number Simply
Insert The Mobile Number witch u Want to Send SMS and Enter SMS Text What
You Want to Send and Click on Send SMS Button. Your SMS Will be Delivered to
Desired Number. You May Send Multiple SMS Simply Add Mobiles Number
Separated by Comma (,) and Enter SMS Text and Hit Send SMS Button to Send
SMS.</font><br/></td>
</tr>
<tr>
<td width="100%"> </td>
</tr>
</table>
<SCRIPT LANGUAGE="JavaScript">
<!-- Dynamic Version by: Nannette Thacker -->
<!-- [url]http://www.shiningstar.net[/url] -->
<!-- Original by : Ronnie T. Moore -->
<!-- Web Site: The JavaScript Source -->
<!-- Use one function for multiple text areas on a page -->
<!-- Limit the number of characters per textarea -->
<!-- Begin
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}
// End -->
</script>
<form name="send_sms" method="POST">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
<tr>
<td width="15%" align="right"><font size="2">Mobile Number(s)</font></td>
<td width="2%" align="center"><font size="2">:</font></td>
<td width="83%">
<INPUT class="text" name="mobile_no" maxlength="50" size="52"></td>
</tr>
<tr>
<td width="15%" align="right"><div style="width: 147; height: 99"><font size="2">Message</font></div></td>
<td width="2%" align="center"><div style="width: 19; height: 101">:</div></td>
<td width="83%"><textarea rows="6" name="message" class="textarea" id="textarea" wrap="physical" onKeyDown="textCounter(document.send_sms.message,document.send_sms.remLen1,160)"
onKeyUp="textCounter(document.send_sms.message,document.send_sms.remLen1,160)" cols="34" maxlength="160"></textarea></td>
</tr>
<tr>
<td width="15%" align="right"> </td>
<td width="2%" align="center"> </td>
<td width="83%"> <input readonly type="text" name="remLen1" size="3" maxlength="3" value="160">
<font size="2">Character Left</font></td>
</tr>
<tr>
<td width="15%" align="right"> </td>
<td width="2%" align="center"> </td>
<td width="83%">
<INPUT type="submit" class="button" name="submit" value="Send SMS">
<INPUT type="reset" class="button" value="Cancel"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
if (isset($_POST['submit']))
{
$message = $_POST['message']; //POST message
$number = $_POST['mobile_no']; //POST number
$numbers = explode(",", $number); //Explode Number with (,)
for ($i=0; $i < count($numbers); $i++)
{
/**
* Define POST URL and also payload
*/
define('XML_PAYLOAD', "<?xml version='1.0' encoding='ISO-8859-1' ?>
<push>
<from>user_id$api_key</from>
<gsm>SAMPLE</gsm>
<cdma>9876543210</cdma>
<message>$message</message>
<mobileno>
<nos>$numbers[$i]</nos>
</mobileno>
</push>");
define('XML_POST_URL', 'http://api.znisms.com/post/xmlsmsv3.asp');
/**
* Initialize handle and set options
*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, XML_POST_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, XML_PAYLOAD);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));
/**
* Execute the request and also time the transaction
*/
$start = array_sum(explode(' ', microtime()));
$result = curl_exec($ch);
$stop = array_sum(explode(' ', microtime()));
$totalTime = $stop - $start;
/**
* Check for errors
*/
if ( curl_errno($ch) ) {
$result = 'ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch);
} else {
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
switch($returnCode){
case 404:
$result = 'ERROR -> 404 Not Found';
break;
default:
break;
}
}
/**
* Close the handle
*/
curl_close($ch);
/**
* Output the results and time
*/
echo 'Total time for request: ' . $totalTime . "\n";
echo $result;
}
}
?>
This only send first string to server the all explode string not sending by it.
Please Help Me.
I Hope Your Understand The above Statement witch i want to Say because i am not expert in english.
Thanx...