php代码使用两个不同的HTTP服务器在同一个php解释器中有两个输出
我正在编写一个代码,其中有两个文件index.php和register.php php包含html表单的代码,如下所示:php代码使用两个不同的HTTP服务器在同一个php解释器中有两个输出,php,apache,xampp,phpstorm,Php,Apache,Xampp,Phpstorm,我正在编写一个代码,其中有两个文件index.php和register.php php包含html表单的代码,如下所示: <form action="register.php" method="POST"> <fieldset> <legend>Personal Information</legend> First Name: <input type="
<form action="register.php" method="POST">
<fieldset>
<legend>Personal Information</legend>
First Name: <input type="text" name="fname">
<br>
<br>
Last Name: <input type="text" name="lname">
<br>
<br>
<input type="submit" name="submit" value="Submit">
</fieldset>
</form>
根据stackoverflow上的另一个答案,我还尝试使用if(isset())来解决此问题,但这会导致未定义的变量错误
那么为什么会发生这种情况呢?问题发生在哪里?我是否错过了在任何配置文件中进行更改?如果是,则需要进行哪些更改或在何处进行更改
使用Xampp服务器和PhpStorm的o/p屏幕截图如下:
两台服务器上的PHP配置不同,
在两台服务器上运行phpinfo()并修复差异。两台服务器上的PHP配置不同, 在两台服务器上运行phpinfo(),并修复差异。试试看
echo $_SERVER['DOCUMENT_ROOT']; //check if the root of the website is the same on both servers
if(!$_SERVER['REQUEST_METHOD']) {
die("Something went REALLY wrong!!!") //reinstall your server conf.
}
if(!$_SERVER['REQUEST_METHOD'] !== 'POST') {
die("We're not getting this request from POST. abort");
}
if(!$_POST) {
die("We're not receiving any data from post.");
} elseif(!$_POST['submit']) {
die("PHP thinks the form wasn't actually submitted");
} else {
if($_POST['fname']) {
//work with your data
} else {
echo "<p>There\'s a problem. We're not getting fname from the form</p>";
}
...
...
}
echo$\u服务器['DOCUMENT\u ROOT']//检查两台服务器上的网站根目录是否相同
if(!$\u服务器['REQUEST\u方法]){
die(“出了什么问题!!!”//重新安装服务器配置。
}
如果(!$\u服务器['REQUEST\u METHOD']!='POST'){
die(“我们没有从POST.abort收到此请求”);
}
如果(!$\u帖子){
死亡(“我们没有从post收到任何数据。”);
}elseif(!$\u POST['submit']){
die(“PHP认为表单实际上没有提交”);
}否则{
如果($_POST['fname'])){
//处理您的数据
}否则{
echo“出现问题。我们无法从表单中获取fname”;
}
...
...
}
我对PHPStorm没有任何经验,但PHPStorm内置服务器的include_路径可能有问题?更重要的是。您是否包含包含路径中的内容?试试看
echo $_SERVER['DOCUMENT_ROOT']; //check if the root of the website is the same on both servers
if(!$_SERVER['REQUEST_METHOD']) {
die("Something went REALLY wrong!!!") //reinstall your server conf.
}
if(!$_SERVER['REQUEST_METHOD'] !== 'POST') {
die("We're not getting this request from POST. abort");
}
if(!$_POST) {
die("We're not receiving any data from post.");
} elseif(!$_POST['submit']) {
die("PHP thinks the form wasn't actually submitted");
} else {
if($_POST['fname']) {
//work with your data
} else {
echo "<p>There\'s a problem. We're not getting fname from the form</p>";
}
...
...
}
echo$\u服务器['DOCUMENT\u ROOT']//检查两台服务器上的网站根目录是否相同
if(!$\u服务器['REQUEST\u方法]){
die(“出了什么问题!!!”//重新安装服务器配置。
}
如果(!$\u服务器['REQUEST\u METHOD']!='POST'){
die(“我们没有从POST.abort收到此请求”);
}
如果(!$\u帖子){
死亡(“我们没有从post收到任何数据。”);
}elseif(!$\u POST['submit']){
die(“PHP认为表单实际上没有提交”);
}否则{
如果($_POST['fname'])){
//处理您的数据
}否则{
echo“出现问题。我们无法从表单中获取fname”;
}
...
...
}
我对PHPStorm没有任何经验,但PHPStorm内置服务器的include_路径可能有问题?更重要的是。是否包含包含路径中的内容?问题似乎出在http服务器的配置中。如果已安装Xampp,则可以将Xampp的apache服务器设置为默认http服务器。您可以在以下链接中找到将Xampp与PhpStorm集成的分步指南(该链接来自PhpStorm的官方供应商):
问题似乎出在http服务器的配置上。如果已安装Xampp,则可以将Xampp的apache服务器设置为默认http服务器。您可以在以下链接中找到将Xampp与PhpStorm集成的分步指南(该链接来自PhpStorm的官方供应商):
这可能完全是由于phpsform使用GET预览/加载
/login\u form/register.php
,而它需要通过表单POST访问才能正常工作。添加一个var_转储($_服务器['REQUEST_METHOD'])代码>在谢谢@kb之后。我尝试过你的解决方案,但它对我不起作用。这可能完全是因为PHPStorm使用GET预览/加载/login\u form/register.php
,而它需要通过表单POST访问才能正常工作。添加一个var_转储($_服务器['REQUEST_METHOD'])代码>在谢谢@kb之后。我尝试了你的解决方案,但它对我无效。不,这不会运行。代码使用Xampp执行得很好,所以我认为问题出在配置文件中。是的,我在LAMP服务器上尝试了这一点,并按预期工作。我想应该归咎于phpstorm。不,这不会运行。代码使用Xampp执行得很好,所以我认为问题出在配置文件中。是的,我在LAMP服务器上尝试了这一点,并按预期工作。我认为这应该归咎于phpstorm。
echo $_SERVER['DOCUMENT_ROOT']; //check if the root of the website is the same on both servers
if(!$_SERVER['REQUEST_METHOD']) {
die("Something went REALLY wrong!!!") //reinstall your server conf.
}
if(!$_SERVER['REQUEST_METHOD'] !== 'POST') {
die("We're not getting this request from POST. abort");
}
if(!$_POST) {
die("We're not receiving any data from post.");
} elseif(!$_POST['submit']) {
die("PHP thinks the form wasn't actually submitted");
} else {
if($_POST['fname']) {
//work with your data
} else {
echo "<p>There\'s a problem. We're not getting fname from the form</p>";
}
...
...
}