KEMPSHOT SPORTS ACADEMY (KSA) - CORE PHP AUTHENTICATION STARTER
================================================================

REQUIREMENTS
- PHP 8.2+
- MySQL 8+ or a compatible MariaDB version
- Apache/Nginx (XAMPP/WAMP/Laragon is fine for localhost)
- PHP mysqli extension enabled

INSTALLATION (LOCALHOST)
1. Create a folder named ksa_authentication inside your web root:
   XAMPP: C:\xampp\htdocs\ksa_authentication
2. Copy this project into that folder.
3. Open phpMyAdmin and import database/ksa_database.sql.
4. Open config/dbconnection.php and set your MySQL host, database, username and password.
5. Visit:
   http://localhost/ksa_authentication/create_admin.php
6. Create the first administrator.
7. DELETE create_admin.php immediately.
8. Visit:
   http://localhost/ksa_authentication/login.php
9. Sign in with the administrator username/email and password.

IMPORTANT
- Do not upload create_admin.php to a live server unless you are performing the initial
  installation, and delete it immediately after use.
- Change the database credentials before online deployment.
- Use HTTPS online.
- Keep config files outside the public web root where possible.
- Back up the database.
- The login throttle is a basic per-username/per-IP control. For production, add monitoring,
  cleanup of old attempts, and hosting-level rate limiting.
- The password reset token table is prepared in the schema, but email/SMS delivery and the
  reset workflow are not implemented in this first authentication milestone.
- Parent-child links, sponsor-player assignments and scout-district scopes will be connected
  when those modules and tables are built.
- Dashboard is a temporary landing page. Individual role dashboards and module pages are
  the next development step.

SECURITY NOTES
- Passwords are stored with PHP password_hash(), never as plain text.
- SQL uses prepared statements.
- Login forms use CSRF tokens.
- Sessions are regenerated after successful login.
- Session cookies are HttpOnly and SameSite=Lax; Secure is enabled under HTTPS.
- Account status is checked.
- Permission checks are server-side using require_permission().
- Do not rely on hiding links or buttons as access control.

USING PERMISSIONS IN A PAGE
At the top of a protected PHP page:

require_once __DIR__ . '/includes/bootstrap.php';
require_permission($conn, 'players.view');

For a page that records vitals:
require_permission($conn, 'vitals.capture');

For restricted medical records:
require_permission($conn, 'medical.view');

The role matrix follows the supplied KSA role document. Team Manager can view vitals,
but does not receive medical.view in this initial seed because the document separately
restricts medical data to Coach, Manager, Academy Director and Admin.

USER MANAGEMENT
After signing in as Admin, open users.php to create academy accounts.
The system generates a temporary password and requires the new user to change it on first login.
