首页 文章

未定义的变量:$ _post xampp server

提问于
浏览
1

我试图运行此代码,但我得到的输出是:

注意:未定义的变量:第4行的E:\ xampp \ htdocs \ testphp.php中的_post

注意:未定义的变量:第5行的E:\ xampp \ htdocs \ testphp.php中的_post

注意:未定义的变量:第6行的E:\ xampp \ htdocs \ testphp.php中的_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>

请帮我!

1 回答

  • 1

    我只是复制粘贴在我的系统中的这个确切的代码,它工作正常 .

    从错误消息中,您似乎从另一个html文件调用了testphp.php . 确保在浏览器中运行它之前保存了更改...两个文件 .

    代码没有任何问题 . 我只是复制粘贴而没有任何修改,它运作良好 .

    有时问题可能出在你的PHP配置文件中 . 请验证你的PHP配置文件是否启用了超全局变量 . 设置开发服务器的最佳方法是单独安装Apache,PHP和MySQL,而不是使用所有包 . 通过了解您的配置,您可以快速解决此类错误 .

    我有一个经验,因为病毒重命名();在PHP中的功能从来没有工作,但重新安装Windows后它没有任何修改 . 所以请验证你是否有任何OS问题 . 尝试在其他系统中使用相同的设置执行你的代码(我坚持这个解决方案,因为你的代码工作正常我的系统!!)

相关问题