-1
新手程序員在這裏。
我想保存在PHP會話變量後的值,但似乎這些變量並沒有得到保存到會話。
我無法讓我的頭周圍POST變量相對於會議的概念,所以我敢肯定,我做了愚蠢的事情這是非常明顯的,但我似乎無法找出什麼。幫助將不勝感激。
碼(some_page.php):
<?php
session_start();
print_r($_SESSION);
if(isset($_POST['cart_items'])){
$_SESSION['item_id'] = $_POST['item_id'];
}
var_dump($_POST);
?>
<html>
<head></head>
<body>
<form method="post" action="some_page.php">
<input name="item_id" value="223">
<button type="submit">Go</button>
</form>
</body>
</html>
這被稱爲[邏輯錯誤](http://en.wikipedia.org/wiki/Logic_error#Debugging_logic_errors)。閱讀關於調試邏輯錯誤的部分,並嘗試在未來調試自己,因爲像這樣的問題對StackOverflow增加了很小的整體價值。 –
如果$ _ POST [「cart_items」]設爲您正在檢查。不是。 – snh