php成员登录系统的html浏览器中未执行文本echo


text echo not executing in html browser for php member login system

在浏览器中打开此php时,表单运行良好。但我无法执行文本echo:

<?php
error_reporting (E_ALL ^ E_NOTICE);
session_start();
?>
<!DOCTYPE html PUBLIC etc etc>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Customer Login | CG Printing</title>
</head>
<body>
    <?php
    $form = "<form action='login.php' method=post'>
    <table>
    <tr>
        <td>Username:</td>
        <td><input type='text' name='user'/></td>
    </tr>
    <tr>
        <td>Password:</td>
        <td><input type='password' name='password'/></td>
    </tr>
    <tr>
        <td></td>
        <td><input type='submit' name='loginbtn' value='Login'/></td>
    </tr>
    </table>
    </form>";
    if ($_POST['loginbtn']){
        $user = $_POST['user'];
        $password = $_POST['password'];
        if ($user){
            if ($password){
                echo "$user - $password <hr /> $form";
            }
            else
                echo "You must enter your password. $form";
        }
        else
            echo "You must enter your username. $form";
    }
    else
        echo $form;
    ?>
</body>
</html>

有人能帮我吗?我不知道哪里出了问题,也不知道为什么回声没有输出到我的浏览器

您忘记在方法分配中打开引号:

method=post'

应该是

method='post'

尝试改变。

它似乎应该输出到您的浏览器,而且很可能是这样——只是不是您期望或看到的地方。

请尝试在浏览器中查看页面的源代码,然后使用Find(ctrl+f)查看源代码中是否有这些语句。

第一个method=post'应该是method='post'

第二个$_POST['loginbtn']应该是isset($_POST['loginbtn'])

第三个session_start()应该在任何命令之前。。。在脚本的顶部。。

第四个$user应该是!empty($user)

第五个$password也应该是!empty($password)

添加这些更改并让我知道。。。。

适当地闭合大括号。

if ($user){
            if ($password)
            {
                echo "$user - $password <hr /> $form";
            }
            else
            {
                echo "You must enter your password. $form";
            }
          }
        else
          {
            echo "You must enter your username. $form";
          }
       }
        else
       {
        echo $form;
       }