使用数据库查找基于输入更新表单类

mefy6pfw  于 2021-06-19  发布在  Mysql
关注(0)|答案(1)|浏览(308)

我不知道从哪里开始。基本上,我希望输入的类更改为 has-success 当数据库表中的用户名 Username 等于用户编写的字符串。表单的当前代码为:

<div class='container col-md-3 rounded p-5 mt-5 border'>
<form action="Authentication.php" method ="post">
    <h3 class='text-center'>Please Login</h3>
    <h5 class='pt-3'>Enter Username and Password</h5>
    <div class="form-group mb-0">
        <input class='form-control float-left mt-3 mb-1' placeholder="Username" type="text" name="username">
        <br>
        <input class='form-control float-left mb-3' placeholder="Password" type="password" name="password">
        <br>
    </div>
    <div class="text-center">
        <input type="submit" class='btn btn-primary btn-sx' value="Login">
    </div>
</form>
</div>

所以每当有人用 placeholder="username" 它需要检查该字符串是否与列中的任何字符串匹配 Username 在table上 Students 如果它真的将类更新为 success .
多谢你的帮助,托比

y1aodyip

y1aodyip1#

如果上面的代码在authentication.php中,并且表单调用了它,那么在检查$post是否已提交的地方,初始化$extraclass='';如果(你的条件为真)$extraclass='成功';
在表格下面,加上
这样,如果不满足条件,它将保持它为空。

相关问题