php · level 3 check

a secure user registry.

Time to ship a real tool: the user registry for a small club's website. People register with an email, a password and a role, then log in. It stores everything in SQLite, refuses bad input with clear messages, and stands up to every attack you met in the security unit.

Your toolkit: a family of exceptions, a backed `Role` enum, a class that receives its `PDO` through the constructor, prepared statements, `password_hash` and `password_verify`, and an `e()` helper that escapes everything shown. `attempt` runs each action as a closure and reports what happened.

Fill in every `____`, run it, and read each line. Then try your own edge cases: an empty password, spaces round an email, a sneaky `<script>` tag.

Fill in every ____ then run the checks.
  1. 1 Good sign-ups go throughuses: classes and databases
  2. 2 Bad input gets a clear messageuses: guard clauses
  3. 3 One account per email, whatever the capitalsuses: custom exceptions and escaping
  4. 4 The right password logs in with the right roleuses: password hashing and enums
  5. 5 A wrong password is refuseduses: password_verify
  6. 6 An injection payload gets nowhereuses: prepared statements

Take as long as you like and try as many times as you want.