A small PHP/MySQL user registration and login application built to practise a few common web security techniques:
- Google reCAPTCHA v2 integration (on registration and password change)
- Session checking and timeout handling
- SQL-injection mitigation (escaped input, parameterised-style queries)
- Basic directory-traversal mitigation
- Real-time client-side password complexity validation
Front end is plain HTML/CSS/JavaScript; the back end is PHP with a MySQLi database connection.
This is a coursework/learning project, not production software.
- Register (
register.php/register_handle.php): new users provide a name, email and password, must solve a Google reCAPTCHA v2 challenge, and get real-time feedback on password complexity (length, upper/lower case, digit, special character) via the bundledjs/jquery.passwordRequirements.jsplugin. Passwords are stored salted and hashed with SHA3-512 (random salt per user). - Login (
index.php/login_handle.php): users log in with email + password (no captcha on this page; reCAPTCHA is only used on register and password-change). On success the app records the client's IP address and login time in the session, and forces a password change if the stored password is more than 30 days old. - Home (
home.php): a landing page for logged-in users listing their last 10 login/logout records (time and IP), read from thelogintable, plus links to change password or log out. - Change password (
password.php/password_handle.php): requires the current password, re-salts and re-hashes the new one, protected by reCAPTCHA and the same real-time complexity check as registration. - Logout (
logout.php): writes a row to thelogintable (email, login time, IP) and destroys the session.
cs_project.sql in this repo is a phpMyAdmin dump of the cs_project
database, containing:
users:id,full_name,email,password(SHA3-512 hex hash),salt,timestamp(date of last password change).login:id,email,login_time,logout_time,ip.
dbconn.php connects to this database as root with no password on
localhost.
- Install PHP and MySQL/MariaDB locally (e.g. XAMPP/WAMP/MAMP, or PHP's built-in server plus a MySQL server).
- Import
cs_project.sqlinto acs_projectdatabase (e.g. via phpMyAdmin ormysql -u root cs_project < cs_project.sql). - Update
dbconn.phpif your MySQL credentials differ from the defaults. - If you want the reCAPTCHA to actually validate, replace the site key in
register.php/password.phpand the secret key inregister_handle.phpwith your own keys from the Google reCAPTCHA admin console. The ones committed here are the original author's test keys and may not work. - Serve the folder with PHP's built-in server, e.g.
php -S localhost:8000from this directory, and openhttp://localhost:8000/index.php.