【问题标题】:Undefined variable: $_post xampp server未定义变量:$_post xampp 服务器
【发布时间】: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 并且没有使用更新版本?

标签: php post xampp


【解决方案1】:

我只是将这段确切的代码复制粘贴到我的系统中,它运行良好。

从错误消息看来,您似乎从不同的 html 文件调用了 testphp.php。确保在浏览器中运行之前保存了更改...两个文件。

代码没有问题。我只是复制粘贴,没有任何修改,效果很好。

有时问题可能出在您的 PHP 配置文件上。请验证是否启用了超全局变量的 PHP 配置文件。设置开发服务器的最佳方法是单独安装 Apache、PHP 和 MySQL,而不是使用软件包all.这让您全面了解您的配置,您可以快速排除此类错误。

我有一个经验,因为病毒 rename(); php中的函数从来没有工作过,但是在重新安装Windows后它没有任何修改就可以工作。所以请验证你是否对操作系统有任何问题。尝试在其他系统中使用相同的设置执行你的代码(我坚持这个解决方案,因为你的代码运行良好我的系统!!)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-07
    • 2018-06-26
    • 2018-11-16
    • 1970-01-01
    • 2016-03-20
    • 2022-12-05
    • 2014-12-20
    • 1970-01-01
    相关资源
    最近更新 更多