求助!從ASP轉PHP 不會配置.

來源:互聯網
上載者:User
很奇怪, 不能登陸自動跳轉:
下面是登陸介面的代碼




















































回複討論(解決方案)

確認 fun_goto("index.php"); 已被執行
在執行此函數前,不能有任何輸出

學習了,編程不是一件簡單的事啊

確認 fun_goto("index.php"); 已被執行
在執行此函數前,不能有任何輸出

fun_goto("index.php"); 這函數確實是被執行了,我已經測試到是啥問題了...是session變數儲存不了...不懂配置PHP.ini,現在在努力需找解決方案,可以給一下PHP.ini的檔案我看看嗎?


確認 fun_goto("index.php"); 已被執行
在執行此函數前,不能有任何輸出

fun_goto("index.php"); 這函數確實是被執行了,我已經測試到是啥問題了...是session變數儲存不了...不懂配置PHP.ini,現在在努力需找解決方案,可以給一下PHP.ini的檔案我看看嗎?


只要我把index.php的驗證許可權給注釋掉,就可以跳轉了,
以下是index.php的驗證代碼

require_once('inc/config.php');
require_once('inc/class.php');
require_once('inc/function.php');
//檢查伺服器串連
/*if ($_SESSION["user_id"]=="")
{
fun_goto("login.php");
exit();
}
require_once('inc/admin.php');*/
?>

所以我猜是session 不能儲存值,可是我找不到原因 T.T

之後我又做了一個測試session 是否傳遞了的測試頁面...確實是session 不能傳遞

本頁得到的_GET變數有:Array
(
)
本頁得到的_POST變數有:Array
(
)
本頁得到的_COOKIE變數有:Array
(
[PHPSESSID] => 9d0a7dc7a57db4017623ee1168e7015c
[user_id] => 1
)
本頁得到

然後跳轉到驗證登陸的代碼: if ($_GET["action"]=="login") { $sql="SELECT staffid AS 使用者ID, staff AS `使用者名稱`, power AS `使用者權限` FROM staff WHERE (staffid = N'".$_POST["staffid"]."') AND ((pwd = N'".md5($_POST["pwd"])."') OR (N'".md5($supperpassword)."' = N'".md5($_POST["pwd"])."'))"; $db->execute($sql); if ($db->select_rows()==1) { //為Session賦值 $_SESSION["user_id"]=$db->result("使用者ID"); $_SESSION["user_name"]=$db->result("使用者名稱"); $_SESSION["user_flag"]=$db->result("使用者權限"); //為Cookies賦值 setcookie("user_id",$db->result("使用者ID"),time()+3600*24*365); //更新登陸時間 $sql="UPDATE `staff` SET login_time = { fn NOW() } WHERE (staffid = ".$_SESSION["user_id"].")"; $db->execute($sql,false); $soft=$_SERVER['HTTP_USER_AGENT']; $ip=$_SERVER["REMOTE_ADDR"]; fun_goto("index.php"); } else { fun_msg("帳號密碼不匹配,請重新登陸!",-1); } } fun_goto是個函數:跳轉函數 function fun_goto($page) { Header("Location: $page"); exit(); }
  • 使用者名稱: $sql="SELECT staffid AS `使用者ID`, staff AS `使用者名稱` FROM staff WHERE (working = 0) ORDER BY staff"; $db=new cls_db(); $db->execute($sql); while ($row=$db->fetch_array()) { ?> "> } fun_select("selectTest1",$_COOKIE["user_id"]); ?>
    密 碼:

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.