Jump to content

Recommended Posts

Posted

Hello @ all,

on my frontend form I use a login throttle with "try" and "catch" and it works well. What I want is to add a counter of the failed login attempts displayed for the user, so the user can always see how many login attempts were done.

Example: Login attempt 1, 2, 3 and so on.

How can I count the number of attempts and output it on the frontend (nothing to store in the database).

Has anyone done something similar in the past and can help me?

Best regards

Posted

Now I got it working :) !

I check again the username in this case, therefore  I grab the username at the beginning of this code.

                        $usernamevalue    = $sanitizer->username($input->post->user);//grab the username after submit
                        $database = $this->wire('database');
                        $name     = $usernamevalue;
                        $query    = $database->prepare("SELECT attempts FROM session_login_throttle WHERE name=:name");
                        $query->bindValue(":name", $name);
                        $query->execute();
                        $numRows = $query->rowCount();
                        if ($numRows)
                            list($attempts) = $query->fetch(PDO::FETCH_NUM);
                        echo $attempts;//this outputs the login attempts

Hope this helps others with the same problem.

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...