Advanced Search
Search Results
89 total results found
Secure Password Storage with Password Hashing
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
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
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 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
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
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
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
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"]...
Backing Up a XAMPP Project
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...
Restoring a XAMPP Project from Backup
Restoring a XAMPP Project from Backup recreates both the website files and the MySQL database. Work from a copy of the backup so the original remains unchanged. Restore project files Install and test XAMPP. Stop Apache and MySQL before replacing project files....
Moving a XAMPP Project to Another Computer
Moving a XAMPP project requires a verified backup of both the project files and its database. Prepare the source computer Save all source files. Export the project database as SQL through phpMyAdmin. Copy the complete project folder from htdocs. Include the S...
New Page
Creating a Security Events Table
In this tutorial, you will create a MySQL table to store security event data imported from a JSON file. The JSON file contains homes, devices and events. Rather than storing the entire JSON structure, each event will be stored as a separate row in a database t...
Importing JSON into MySQL with PHP
This tutorial imports a fictional JSON dataset into MySQL using PHP, PDO, validation and a prepared statement. Use fictional data only. Do not import real student, staff, account, device or school-security information. Project files Create this structure insid...
Querying Imported Data with SQL
In this tutorial, you will use SQL queries to analyse the imported data. View All Events Open phpMyAdmin and select the: security_events table. Run: SELECT * FROM security_events; This displays all imported records. Count All Events To find the total number of...
Building a Security Dashboard Using PHP and MySQL
This standalone example queries fictional security-event data with PDO and presents useful summary and detail output. A dashboard is meaningful when each output answers a user question. Do not add a statistic or chart merely because it is easy to calculate. Co...
Loading JSON Data with JavaScript
In this tutorial, you will load data from a JSON file and display it on a webpage using JavaScript. The JSON file contains information about a smart home, including devices and security events. Create the Project Files Create a new folder called: json-demo Ins...
Displaying JSON Data in a Table
In this tutorial, you will display the device data in an HTML table using JavaScript. Current Project Structure Your project should contain: json-demo ├── index.html ├── script.js └── smart_security_data.json Create a Table Container Open: index.html Update th...