首先,我正在使用 wamp 服务器并学习基本的 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;
?>
但是当我打开 localhost/form2.php 时它工作正常,然后我输入“用户名”和“电子邮件”。之后,它给出了以下错误:
注意:未定义变量:第 13 行 C:\wamp\www\foo.php 中的 HTTP_POST_VARS 注意:未定义变量:第 19 行 C:\wamp\www\foo.php 中的用户名
显然,这些代码应该可以工作,但由于某种原因它对我不起作用。wamp服务器有问题吗?或者我如何设置配置可能有问题?谢谢 !