echo "<form action='' id='customForm' method='post'>";
                                echo "<div>";
                                    $mobile = $_SESSION['mobile'];
                                    echo "<label for='name'>From : $mobile</label>";
                                echo "</div>";
                                echo "<div>";
                                    echo "<label for='name'>Sender Mobile number</label>";
                                    echo "<input type='text' name='recipient' id='mobile' class='error'>";
                                    echo "<span id='nameInfo' class='error'> Mobile number must contain only 10 digits</span>";
                                echo "</div>";
                                echo "<div>";
                                    echo "<label for='email'>Message &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;your sms balance : {$udata['sms']}</label>";
                                    echo "<textarea onKeyDown='limitText(this.form.smessage,this.form.countdown,140);' onKeyUp='limitText(this.form.smessage,this.form.countdown,140);' maxlength='140' name='message' id='message'></textarea>";
                                    echo "<span id='emailInfo' class='error'> Message boy supports 140 charecters :P</span>";
                                echo "</div>";
                                echo "<div>";
                                echo "You have <input readonly type='text' id='limited' name='countdown' size='3' value='140'> characters left.</font>";
                                echo "</div>";
                                    echo "<div>";
                                        echo "<input type='submit' value='Send' name='send' id='send'>";
                                    echo "</div>";
                            echo "</form>";

Receiving in POST Method:

        if(isset($_POST["send"]))
                            {
                                $recipient = $_POST["recipient"];
                                $message = $_POST["message"];
                                if($recipient == "" || $message == "")
                                {
                                    echo "<div cloass='error'>are you kidding ? enter something to act</div>";
                                }
                                else
                                {
                                    $recipient = $_POST["recipient"];
                                    $message = $_POST['message'];

                                    $gateway = "http://127.0.0.1:8080/api?action=sendmessage&username=admin&password=admin&recipient=NNNNN&messagetype=SMS:TEXT&messagedata=MMMMM";
                                    $gateway = str_replace("NNNNN", $recipient, $gateway);
                                    $message = str_replace("", "+", $message);
                                    $gateway = str_replace("MMMMM", $message, $gateway);

                                    $r= new HttpRequest($gateway, HttpRequest::METH_POST);
                                    try
                                    {
                                        $r->send();
                                        echo "<div cloass='error'>Message sent to : $recipient</div>";
                                    }
                                    catch (HttpException $ex)
                                    {
                                        echo $ex;
                                    }
                                }
                            }

Am not able to send sms using this script, can any one find the error thanks in advance..

You should write more information, you get the data from the form? You still display the correct data after you do str_replace()? Have you tried to get response code? Right after r->send(); write:

try
{
    $r->send();
    echo $r->getResponseCode(); # so you know if the request reaches the gateway
    echo "<div cloass='error'>Message sent to : $recipient</div>";
}
Be a part of the DaniWeb community

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