doutou19761022 2016-12-28 08:30
浏览 57

短信在localhost上运行完美,但在线它无效

<?php
if(isset($_POST["submit"]))
{
$adm=$_POST["admno"];
$phn=$_POST["phn1"];
include("model.php");
$db = new database;
$r=$db->register($adm);
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);
$pre = 'Dear%20Parents,Your%20Password%20is%20';
$suf = '%20ThankYou.CV';
$sms = $pre.$password.$suf;

$ch = curl_init("http://www.perfectbulksms.in/Sendsmsapi.aspx
USERID=ID&PASSWORD=Pass$&SENDERID=SID&TO=$phn&MESSAGE=$sms");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
$result = curl_exec($ch);
curl_close($ch);
header("Location:password.php?msg=new"); 

}
else
{
header("Location:register.php?msg=invalid");

}
}
}
?>

this code working perfectly on local host but online it takes too long to going next page and it is not sending sms to phone when online. although it is generating the password but not sending it to phone and taking too much time for generating it. but on local host it is sending msg.

  • 写回答

1条回答 默认 最新

  • 普通网友 2016-12-28 08:39
    关注

    Try this before curl_close to find out the problem.

    if( $result === false)
    {
        echo 'Curl error: ' . curl_error($ch).' '.curl_errno($ch);
    }
    

    Seem like connection timeout problem between your and sms's server.

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line