【问题标题】:checking if password is equals user password Laravel 7检查密码是否等于用户密码Laravel 7
【发布时间】:2020-06-19 21:30:06
【问题描述】:

我有这个代码

<form action="form.php" method="post">
    <input type="password" name="password">
    <input type="submit" name="submit">
</form>

@isset($_POST['submit'])
    @if(password==user password or sth like that)
        <p>the pasword is correct</p>
@else
    <p>the pasword is wrong</p>
    @endif
  @endisset

我需要输入什么 @if(password==user password or sth like that) 才能使用密码检查?

【问题讨论】:

  • 你可以使用 \Auth::attempt 但如果可能的话你应该使用 laravel 的样板方法

标签: laravel laravel-7


【解决方案1】:

如果您想在 laravel 上执行此操作,请查看此链接 here。您应该在控制器上进行此控制。

但是如果你想在 form.php 上这样做,那么首先连接你的数据库并像这样检查它

if($_POST['password'] == $user_password_from_database) 

还要小心哈希函数。如果您使用任何哈希函数保存了密码,那么您应该对其进行解码。祝你好运

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-24
    • 1970-01-01
    • 1970-01-01
    • 2016-11-25
    • 2014-05-20
    • 1970-01-01
    • 2020-01-04
    • 2016-12-13
    相关资源
    最近更新 更多