2012-10-08 41 views
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>'; 

?> 
+0

curl不會干擾現有會話(除非您通過curl請求PHP代碼,然後eval()it)。確認你在其他頁面上調用了'session_start()'。 –

+2

請不要使用'mysql_ *'函數來編寫新代碼。他們不再維護,社區已經開始[棄用程序](http://goo.gl/KJveJ)。請參閱* [紅盒子](http://goo.gl/GPmFd)*?相反,您應該瞭解[準備好的語句](http://goo.gl/vn8zQ)並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli的)。如果你不能決定哪些,[這篇文章](http://goo.gl/3gqF9)會幫助你。如果你選擇PDO,[這裏是很好的教程](http://goo.gl/vFWnC)。 –

+0

我已經召集會議開始到處..我找不到原因.. –

回答

1

這是挺有意思的......你知不知道你叫捲曲之前關閉PHP ???

刪除?>形式中,把它放在頁面的末尾

其次,我不建議,繼續使用mysql_query

從PHP DOC

這個擴展的使用灰心。相反,應該使用MySQLi或PDO_MySQL擴展。另請參閱MySQL:選擇API指南和相關FAQ以獲取更多信息。此功能的替代方案包括:

+0

我確實有一個打開php標籤之前實際上捲曲..我沒有打印在這裏! –

+0

@Blerta Blerta然後你給我們錯誤的信息..你如何期待我們以這種方式幫助你.. – Baba

+0

我想你會說我,我給的信息是無用的,我需要減少它..在一分鐘內我會打印真實的信息.. –