Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.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 - Fatal编程技术网

Php 这个post方法代码可能有什么问题?

Php 这个post方法代码可能有什么问题?,php,html,Php,Html,我对下面的php代码有一个问题。我试图提交密码,而提交是成功的php的回声部分显示在网页上,但没有得到任何错误或响应 <html> <head> <title>POST METHOD</title> </head> <body> <form action="login.php" method="post"> Please enter your password:<br>

我对下面的php代码有一个问题。我试图提交密码,而提交是成功的php的回声部分显示在网页上,但没有得到任何错误或响应

<html>
<head>
    <title>POST METHOD</title>
</head>
<body>
    <form action="login.php" method="post">
        Please enter your password:<br>
        <input type="password" name="pwd" value="password"><br><br>
        <input type="submit" name="Submit">
    </form>
</body>
</html>


<?php
    $password='password';
    if(isset($_POST['password']) &&!empty($_POST['password'])){
        echo 'submtted and filled';
    }
?>

POST方法
请输入您的密码:



您在帖子中使用了错误的名称:您需要使用
pwd
而不是
password

if(isset($_POST['pwd']) && !empty($_POST['pwd'])){

     echo 'submtted and filled';

}

您好,您需要在post方法中使用name,以获取任何文本/其他字段的值。但在您的代码中,您使用的是类型(密码),这就是为什么您的密码不会出现在服务器端。你可以使用下面的代码,我希望它可以工作

<html>
<head>
    <title>POST METHOD</title>
</head>
<body>
    <form action="login.php" method="post">
        Please enter your password:<br>
        <input type="password" name="pwd" value="password"><br><br>
        <input type="submit" name="Submit">
    </form>
</body>

POST方法
请输入您的密码:



这两段代码是否在同一个文件中?那个文件名为
login.php
<?php

if(isset($_POST['pwd']) && $_POST['pwd'] !='')
{
  echo 'submtted and filled';
}
 else
{
   echo 'Something went wrong please try again';
}


?>