简体   繁体   English

未定义的变量:$ _post xampp服务器

[英]Undefined variable: $_post xampp server

I tried to run this code ,but the output I got was: 我尝试运行此代码,但是得到的输出是:

Notice: Undefined variable: _post in E:\\xampp\\htdocs\\testphp.php on line 4 注意:未定义的变量:第4行E:\\ xampp \\ htdocs \\ testphp.php中的_post

Notice: Undefined variable: _post in E:\\xampp\\htdocs\\testphp.php on line 5 注意:未定义变量:第5行E:\\ xampp \\ htdocs \\ testphp.php中的_post

Notice: Undefined variable: _post in E:\\xampp\\htdocs\\testphp.php on line 6 注意:未定义的变量:E:\\ xampp \\ htdocs \\ testphp.php中的_post在第6行

First Name:- Last Name:- Other Details : 名:-姓:-其他详细信息:

This is the code of my form: 这是我形式的代码:

<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>

This is the code in testphp.php: 这是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>

Please help me! 请帮我!

I just copy pasted this exact code in my system and it worked fine. 我只是将这个确切的代码复制粘贴到了我的系统中,并且工作正常。

from the error message it seems like you called the testphp.php from a different html file.Make sure you saved the changes before running it in browser...both files. 从错误消息中看来,您似乎是从其他html文件中调用了testphp.php。确保在浏览器中运行它们之前都保存了更改...两个文件。

There is nothing wrong with the code.I just copy pasted without any modification and it worked well. 代码没有错,我只是复制粘贴而没有任何修改,并且效果很好。

Sometimes the problem may be with your PHP configuration file.Please verify your PHP configuration file for superglobal variables is enabled or not.The best way to setup a development server is by individullay installing Apache,PHP and MySQL instead of using Packages of all.This gives you a through knowledge of your configurations and you can quickely troubleshoot errors of this sort. 有时问题可能出在您的PHP配置文件上。请验证您的PHP配置文件是否启用了超全局变量。设置开发服务器的最佳方法是分别安装Apache,PHP和MySQL,而不要使用所有软件包。为您提供有关配置的全面知识,并且您可以快速排除此类错误。

I had an experience where because of a virus the rename(); 我有一个经历,因为病毒,rename(); function in php never worked,but after reinstalling windows it worked without any modifications.So please verify if you have any problem with OS.Try executing your code in other system with the same setup(I insists on this solution because your code worked fine on my system!!) php中的函数无法正常工作,但是重新安装Windows后,它无需任何修改即可正常工作。因此,请验证您的操作系统是否有问题。尝试在具有相同设置的其他系统中执行代码(我坚持使用此解决方案,因为您的代码在我的系统!)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM