繁体   English   中英

使用cURL函数后,会话将无法正常工作

[英]After using cURL function, the session won't work

我有一个具有登录用户的脚本,因此用户只能使用其用户名/密码登录!

一切正常,唯一的问题是,在页面中我使用了cURL函数,一旦我离开该页面并移至另一个页面,它将不再识别用户会话。

这是cURL文件代码:

<?php session_start(); 
require_once('db.php'); 
include('functions.php'); 
checkLogin('1'); 
$query = 'SELECT * FROM users WHERE ID="'.$_SESSION['user_id'].'"';
$result = mysql_query($query) or die(mysql_error());


while($row = mysql_fetch_array($result)){
    $id_user=$row['user_id'];
    $phone=$row['phone'];
    $name=$row['first_name'];


}

?>

<?php
    if ($points == 250) {
     $b = time (); 
 $date1 =date( "Y-m-d;h:i:s" , mktime(date("h")+6, date("i"), date("s"), date("m") , date("d"), date("Y"))); 
 $str_time = ""; 
 $str_msg = ""; 
 $str_from = ""; 
 $str_zip = ""; 

$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://testext.i-movo.com/api/receivesms.aspx?".$str_from.$str_zip.$phone.$str_time.$date1.$str_msg);
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);
}
else if ($points == 500) {
     $b = time (); 
 $date1 =date( "Y-m-d;h:i:s" , mktime(date("h")+6, date("i"), date("s"), date("m") , date("d"), date("Y"))); 
 $str_time = ""; 
 $str_msg = ""; 
 $str_from = ""; 
 $str_zip = ""; 

$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://testext.i-movo.com/api/receivesms.aspx?".$str_from.$str_zip.$phone.$str_time.$date1.$str_msg);
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);
}
else {
    echo "We are sorry, you don't possess enough points in order to take the coupon";

}
echo '</div>';

?>

这是非常有趣的...您知道在调用curl之前关闭了php吗???

删除?>从中间放在页面末尾

其次,我不建议继续使用mysql_query

从PHP DOC

不鼓励使用此扩展名。 相反,应使用MySQLi或PDO_MySQL扩展。 另请参见MySQL:选择API指南和相关的FAQ,以获取更多信息。 此功能的替代方法包括:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM