CURL网址调用后页面空白

时间:2016-05-10 13:27:24

标签: php curl sms

我打电话给CURL发送短信,工作正常。但在调用页面空白后显示如下。下面是我的代码和屏幕截图 enter image description here

这是我的代码

if(isset($_POST['btnAddProduct']))
{
    $msgUser = $_POST['txtSMS'];
$phone = "";
$fields_string = "";
foreach($_POST['check_list'] as $selected){
   $phone .=$selected.",";
}
$phone = rtrim($phone,',');
$url = 'http://www.sms.com/PostSms.aspx';
$fields = array(
                    'userid' => urlencode('username'),
                    'pass' => urlencode('pwd'),
                    'phone' => urlencode($phone),
                    'msg' => urlencode($msgUser),
                    'title' => urlencode('code')
                );

foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//echo $fields_string;exit;
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post
//$result = curl_exec($ch);
//close connection
curl_close($ch);
?>
    <script type="text/javascript">
        alert("Message sent successfully");
        window.location ="sms.php";
    </script>
<?php 
}

0 个答案:

没有答案