0

我有这个脚本,它有一个登录用户,所以用户只能使用他的用户名/密码登录!

一切正常,唯一的问题是,在我使用 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>';

?>
4

1 回答 1

1

这很有趣......你知道你在调用 curl 之前关闭了 php 吗?

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

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

来自 PHP 文档

不鼓励使用此扩展程序。相反,应该使用 MySQLi 或 PDO_MySQL 扩展。另请参阅 MySQL:选择 API 指南和相关的常见问题解答以获取更多信息。此功能的替代方案包括:

于 2012-10-08T11:37:29.693 回答