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

php成员登录系统的html浏览器中未执行文本回显,php,Php,在我的浏览器中打开此php时,表单工作正常。但我无法执行文本回显: <?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</t

在我的浏览器中打开此php时,表单工作正常。但我无法执行文本回显:

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

客户登录| CG打印

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

method=post'
应该是

method='post'

试着改变

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


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

适当地关闭大括号

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;
       }
if($user){
如果($password)
{
回显“$user-$password
$form”; } 其他的 { echo“您必须输入密码。$form”; } } 其他的 { echo“您必须输入用户名$form”; } } 其他的 { 回声$形式; }
首先
method=post'
应该是
method='post'

第二个
$\u POST['loginbtn']
应该是
isset($\u POST['loginbtn'])

第三个
会话\u start()
应该在任何命令之前。。。在脚本的顶部

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

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


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

OMG谢谢,已经为此工作了几个小时。这样愚蠢的错误。谢谢:)另外,我相信他的else语法在每种情况下都缺少“{”一个。@itachi,你会对那条评论投反对票,就像我对我的答案lol一样。我测试了一下它是否是一个替代语法,但它抛出了一个解析错误。我确信其他语法应该正确地用括号括起来{'也是。这可能不是全部答案,但它解决了一部分问题。至少它不应该得到我的下一票。+1。我很惊讶为什么OP或其他人没有得到解析错误。你也能检查一下吗?在一行程序中保留大括号是完全可以的(虽然不是一个好的做法)。这和OP的代码之间没有实际的区别。