【发布时间】:2014-07-01 10:53:16
【问题描述】:
我尝试运行这段代码,但得到的输出是:
注意:未定义变量:E:\xampp\htdocs\testphp.php 第 4 行中的 _post
注意:未定义变量:E:\xampp\htdocs\testphp.php 第 5 行中的 _post
注意:未定义变量:E:\xampp\htdocs\testphp.php 第 6 行中的 _post
名字:- 姓氏:- 其他详细信息:
这是我的表单代码:
<html>
<body>
<form method="post" action="testphp.php">
<label for="firstname">First Name: </label>
<input type="text" id="firstname" name="firstname" /> </br></br>
<label for="lastname">Last Name: </label>
<input type="text" id="lastname" name="lastname" /> </br></br>
<label for="other"> Other Details: </label>
<textarea name="other" ></textarea></br></br>
<input type="submit" value="Ok -- submit" name=submit />
</form>
</body>
</html>
这是testphp.php中的代码:
<html>
<body>
<?php
$first_name = $_POST['firstname'];
$last_name= $_POST['lastname'];
$otherdetail= $_POST['other'];
echo 'First Name:- '. $first_name;
echo 'Last Name:- '. $last_name;
echo 'Other Details :- '. $otherdetail;
?>
</body>
</html>
请帮帮我!
【问题讨论】:
-
知道为什么错误消息中有一个小写的
_post吗? -
+ 你确定你是使用表单进入脚本的吗?
-
在
name=submit中加上引号 -
尝试使用 get 方法,只是为了知道它是否是某种系统错误。我有一个经验,因为病毒 rename(); php中的函数从来没有工作过,但是在重新安装windows后它没有任何修改就可以工作
-
代码没问题。这没什么错。您确定您正在运行这些确切的文件,并且您可能一开始使用的是
$_post而不是$_POST并且没有使用更新版本?