Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP Post方法错误_Php_Html_Post - Fatal编程技术网

PHP Post方法错误

PHP Post方法错误,php,html,post,Php,Html,Post,我在我的网站上使用Post方法。在my index.html文件中有以下代码: <!DOCTYPE html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Heater Login</title> <link rel="stylesheet" href="css/s

我在我的网站上使用Post方法。在my index.html文件中有以下代码:

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Heater Login</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<form method="post" action="login.php" class="login">
<p>
<label for="login">Username:</label>
<input type="text" name="login" id="login" value="John Appleseed">
</p>

<p>
<label for="password">Password:</label>
<input type="password" name="password" id="password" value="4815162342">
</p>

<p class="login-submit">
<button type="submit" class="login-button">Login</button>
</p>

</form>

</body>
</html>
<?php
echo($_POST['login']);
echo($_POST['password']);
?>

加热器登录

用户名:

密码:

登录

在我的login.php文件中有以下代码:

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Heater Login</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<form method="post" action="login.php" class="login">
<p>
<label for="login">Username:</label>
<input type="text" name="login" id="login" value="John Appleseed">
</p>

<p>
<label for="password">Password:</label>
<input type="password" name="password" id="password" value="4815162342">
</p>

<p class="login-submit">
<button type="submit" class="login-button">Login</button>
</p>

</form>

</body>
</html>
<?php
echo($_POST['login']);
echo($_POST['password']);
?>


当我打开html文件时,输入我的凭据,单击提交按钮,它将转到php文件结尾,没有任何内容。

你能用新代码更改这行代码吗?希望它能正常工作

<button type="submit" class="login-button">Login</button>

<input type="submit" name="submit" value="Login"> 
登录

最后,我希望您从stackoverflow复制整个代码并使用此代码。有时空间可能会产生问题。

当您直接从文件位置打开文件时,会出现此问题,请尝试从服务器打开文件
例如,如果您使用xampp open localhost,然后再试一次。

这有什么帮助,@Fred ii-?To:
OP
。你的代码没有问题。你这方面显然有问题,可能有很多问题。这显然不是完整的代码。@AmalMurali如果URL错误,他会得到一个
404
错误。@AmalMurali您的服务器一定在进行重写和重定向。只有当表单的URL为
http://localhost/test.php/
结尾有一个额外的
/
。不带路径前缀的URL应解析为与当前URL相同的目录。它们都是相同的,将提交表单。带有
类型的
作为
提交的
与类型设置为
提交的
相同(除了一些IE版本的错误)。
然后再试一次
你能说得更具体些吗?