PHP 在同一页面上发布

标签 php html

我有这个代码,我想在 password = hello 时发送消息。 但是页面立即显示文本:'good pass' 和 'bad pass'

这段代码有什么问题?

<body>
<?php
if(isset($_POST['submit'])) 
{
    $wachtwoord = ($_POST['wachtwoord']);

    if ($wachtwoord = "hello")
    {
     ?><h1>Good pass</h1><?php;
    }

    else 

    if($wachtwoord != "hello")
    {
    ?><h1>Wrong pass.</h1><?php;
    }
} 

else 
{
?>
<center>
    <br><br><br><br>
        <table>
            <tr><td>Hello User, <br><br><hr>
            <b><a href="link0/">DirectAdmin</a><br><br>
            <a href="link1/">PHPMyAdmin</a></b><br>
            <form action="" method="POST">
            <input name="wachtwoord" type="text" /><input type="submit" name="submit" value="Go" /></td></tr>
            </form>
        </table>
    <br><br>
    </center>
<?php
}
?>
</body>

最佳答案

您现在是 assigning if ($wachtwoord = "hello") 带有一个等号 =

像这样使用两个:== 然后按顺序执行 if ($wachtwoord == "hello") to compare .


关于PHP 在同一页面上发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25524164/

相关文章:

php - MySQL 将行转置为列标题 php html 表

php - 类实例化语法 - 看不懂

php - Laravel 中的地址验证

php - 使用 PHPMailer 发送电子邮件 - 在正文中嵌入图像

javascript - 一些挑剔的 HTML、CSS 和 JS 问题

php - 上传时无法创建临时文件

javascript - 增加 Canvas 中形状的边框宽度

JQuery 获取除某些 TD 之外的表的 HTML

javascript 将 YouTube 链接转换为嵌入视频

html - 如何将 nth-child() 规则合二为一?