通过javascript命令发送短信因为curl在服务器上不起作用?

时间:2017-03-18 05:10:53

标签: javascript php html5

 $adm=$_POST["admno"];
$phn=$_POST["phn1"];
include("model.php");
$db = new database;
$r=$db->register($adm,$schoolcode);
while($row=mysql_fetch_array($r))
{
    if($row["phn_no1"]==$phn  || $row["phn_no2"]==$phn  ||   $row["phn_no3"]==$phn)
{
    $formatted = "".substr($phn,6,10)." ";
    $password = $formatted + $adm;
    echo $password;
    $db->setpassword($adm,$password,$schoolcode);
    $pre = 'Dear%20Parents,Your%20Password%20is%20';
    $suf = '%20ThankYou.CV';
    $sms = $pre.$password.$suf;
    session_start();
            ?>
     <script>
        window.onload = function(){
        {
            $("#active"+id).css({"color":"red"});
            var http = new XMLHttpRequest();
             var url = "http://www.perfectbulksms.in/Sendsmsapi.aspx?USERID=UID&PASSWORD=UPASS$&SENDERID=SID&TO=<?php echo $phn; ?>&MESSAGE=<?php echo $sms;?>";
             var adm = "<?php echo $admno; ?>";
            var params = "Id="+ id +"&adm="+adm;
            http.open("POST", url, true);
            http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            http.onreadystatechange = function() {
            if(http.readyState == 4 && http.status == 200) {
            //alert(http.responseText);
                        }
            }
            http.send(params);
            window.location.href="#";
        }
        };
        </script>
     <?php
     header("Location:password.php?msg=new"); 

此代码无效..好吧,根据代码更改我的密码但不发送短信..我没有使用curl命令,因为它在localhost上工作正常,但在服务器上它无法工作..

1 个答案:

答案 0 :(得分:0)

这不是正确的方法,如果您的服务器上没有CURL,那么安装它然后使用CURL。

CURL安装过程在此处定义:

Help Doc

Help Doc