Advertisement
serpentiny

05.Login

Oct 3rd, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.44 KB | None | 0 0
  1. <?php
  2.  
  3. $user = readline();
  4. $counter = 0;
  5. $reverseUser = strrev($user);
  6. while (true) {
  7.     $password = readline();
  8.     if ($password == $reverseUser) {
  9.         echo "User $user logged in.";
  10.         break;
  11.     }
  12.     if ($password != $reverseUser && $counter <= 3) {
  13.         echo 'Incorrect password. Try again.' . PHP_EOL;
  14.         $counter++;
  15.     }
  16.     if ($counter > 3) {
  17.         echo "User $user blocked!";
  18.         break;
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement