Error: Invalid Parameter

Error: Invalid Parameter SearchSearch
Author Message
Dec Donnelly
Unregistered guest
Posted on Wednesday, April 21, 2004 - 02:07 am:   

I two php files one called message.php and sendmess.php both are stored in my wwwroot folder. message.php is form which allows the user to enter phone number and text message. When user clicks on Send its action is set to sendmess.php but the following appears when user clicks send. Code for message.php and sendmess.php can be seen below:
auth: username:password auth: dXNlcm5hbWU6cGFzc3dvcmQ= HTTP/1.0 400 Bad Request Content-type: text/html Expires: Tue, 01 Jan 1980 1:00:00 GMT Cache-Control: no-cache
Error: Invalid Parameter
Invalid format for telephone number.

message.php
<form method="post" action="sendmess.php">

<tr class='forumrow'><td>Mobile Number:</td><td><p>
<input type='text' name='phoneNoRecip' size='11'>
</p>
<p> <br>
</p></td></tr>
<tr class='forumrow'>
<td><p>Text Message</p>
<p>

</p></td><td><textarea name="message" cols="15" rows="10" id="message"></textarea>
<input type="submit" name="Submit" value="Send">
</form>
</table>

sendmess.php
?

function SendSMS ($host, $port, $username, $password, $phoneNoRecip, $msgText) {

$fp = fsockopen($host, $port, $errno, $errstr);
if (!$fp) {
echo "errno: $errno \n";
echo "errstr: $errstr\n";
return $result;
}

fwrite($fp, "GET /?Phone=" . rawurlencode($phoneNoRecip) . "&Text=" . rawurlencode($msgText) . " HTTP/1.0\n");
if ($username != "") {
$auth = $username . ":" . $password;
echo "auth: $auth\n";
$auth = base64_encode($auth);
echo "auth: $auth\n";
fwrite($fp, "Authorization: Basic " . $auth . "\n");
}
fwrite($fp, "\n");

$res = "";

while(!feof($fp)) {
$res .= fread($fp,1);
}
fclose($fp);


return $res;
}



$x = SendSMS("127.0.0.1", "8800", "username", "password", "", "");
echo $x;


?>


Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 2344
Registered: 10-2002
Posted on Thursday, April 22, 2004 - 04:21 pm:   

Hi Dec,

You need to modify sendmess.php so that it parses the variables that are passed to it.

Right now, sendmess.php does not parse any variables that are passed to it, it only connects to the NowSMS server and passes a blank phone number field, and a blank message text field.

I just posted an example of how to do this yesterday in the following thread:

http://support.nowsms.com/discus/messages/1/3692.html

Use sendsmsscript.php from that thread in place of your sendmess.php.

To use sendsmsscript.php from that thread directly, change the form in your message.php so that the form variable names are "phone" and "text" (as those are the variable names that "sendsmsscript.php" parses).

-bn