首先,我使用了wamp服務器並學習了基本的PHP語法。php窗體標籤不工作? (未定義的變量錯誤)
所以我的第一種形式的PHP文件是
<form action="foo.php" method="post">
Name: <input type="text" name="username" /><br />
Email: <input type="text" name="email" /><br />
<input type="submit" name="submit" value="Submit me!" />
</form>
和foo.php文件
<?php
// Available since PHP 4.1.0
echo $_POST['username'];
echo $_REQUEST['username'];
import_request_variables('p', 'p_');
echo $p_username;
// As of PHP 5.0.0, these long predefined variables can be
// disabled with the register_long_arrays directive.
echo $HTTP_POST_VARS['username'];
// Available if the PHP directive register_globals = on. As of
// PHP 4.2.0 the default value of register_globals = off.
// Using/relying on this method is not preferred.
echo $username;
?>
但是當我打開本地主機/ form2.php它工作正常,然後我輸入「用戶名「和」電子郵件「。之後,它提供了以下錯誤:
說明:未定義變量:HTTP_POST_VARS在C:\瓦帕\ WWW \ foo.php上線13 說明:未定義變量:用戶名在C:\瓦帕\ WWW \ foo.php在線19
顯然,這些代碼應該工作,但它由於某種原因不適合我。 wamp服務器有問題嗎?或者如何設置配置可能有問題?謝謝 !
呃......因爲$的用戶名是未定義線19拋出一個錯誤... – diagonalbatman 2013-03-26 21:44:53
$ HTTP_POST_VARS已經過時;見http://php.net/manual/en/reserved.variables.post.php – Don 2013-03-26 21:45:14
你使用什麼PHP版本? <?php echo phpinfo()?> – 2013-03-26 21:47:13