Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

114 total results found

Programming Tutorials

Practical programming tutorials and examples.

PHP and MySQL

Standalone tutorials for building secure PHP and MySQL web applications with PDO, validation, sessions and role-based access.

New Page

PHP and MySQL

Login Systems

PHP and MySQL

Build secure registration, login, sessions, protected pages and user/admin role-based access with PDO.

Creating a User Database and Table Using SQL

PHP and MySQL Login Systems

A login system needs a users table that can identify accounts, store password hashes and enforce roles. This example uses fictional accounts and prepares the database for PDO-based PHP pages. Never store plain-text passwords. The password field below stores t...

New Page

PHP and MySQL Login Systems

Secure Password Storage with Password Hashing

PHP and MySQL Login Systems

Password hashing converts a password into a one-way value suitable for storage. PHP automatically includes a salt, so the same password can produce different valid hashes. Use fictional test passwords only. Never enter your school, email, banking or reused per...

Creating a User Registration Form

PHP and MySQL Login Systems

This standalone registration page accepts a fictional username and password, validates both on the server, hashes the password and inserts a standard user account with PDO. Database connection The example expects includes/db.php to create a PDO object named ...

Creating a Login Form

PHP and MySQL Login Systems

This standalone login page validates credentials with PDO, starts a secure session and redirects authenticated users. It uses one generic failure message so it does not reveal whether a username exists. Login page <?php session_start(); require __DIR__ . "/inc...

Using PHP Sessions to Keep Users Logged In

PHP and MySQL Login Systems

PHP sessions store a small amount of trusted server-side state between requests. A login system can use them to remember the authenticated user’s identifier, username and role. Start the session Call session_start() before HTML or other output: <?php session_...

Protecting Pages and Preventing Unauthorised Access

PHP and MySQL Login Systems

A protected page checks authentication on the server before sending restricted content. Hiding a menu link is not protection because a user can enter the URL directly. Require a logged-in user Place this before any HTML: <?php session_start(); if (!isset($_SES...

Creating a Logout Page

PHP and MySQL Login Systems

Logout should remove server-side session data, expire the session cookie and return the user to a safe public page. Logout script Create logout.php: <?php session_start(); $_SESSION = []; if (ini_get("session.use_cookies")) { $parameters = session_get_coo...

Adding Role-Based Access Control

PHP and MySQL Login Systems

Role-based access control allows authenticated users to perform only the actions permitted by their stored role. This example uses two roles: user and admin. Database role A suitable users table contains: role VARCHAR(20) NOT NULL DEFAULT 'user' Ordinary reg...

Creating a Navigation Menu Based on User Roles

PHP and MySQL Login Systems

Role-aware navigation shows users the actions available to them. It improves usability, but server-side checks remain responsible for security. Start with a protected page <?php require __DIR__ . "/includes/require-login.php"; $username = $_SESSION["username"]...

Working with Data

Tutorials for importing, processing, querying and presenting fictional data with PHP, MySQL, JavaScript and charts.

Developer Toolbox

Practical tools and guides for setting up, checking, backing up and recovering local web-development projects.

XAMPP Backup and Recovery

Developer Toolbox

Back up, restore and transfer both XAMPP project files and MySQL databases safely.

Backing Up a XAMPP Project

Developer Toolbox XAMPP Backup and Recovery

A working XAMPP project normally has two separate parts: website files inside htdocs and data stored in MySQL. A complete backup needs both. Back up project files Stop active editing and save every file. Locate the project folder inside htdocs. Copy the enti...