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

Creating a MySQL Database with phpMyAdmin

Developer Toolbox XAMPP Setup and Projects

A database organises persistent information in related tables. This practice creates a small fictional database without prescribing an assessed design. Create the database Start Apache and MySQL. Open http://localhost/phpmyadmin/. Select Databases. Create ca...

Checking a Project Before Development

Developer Toolbox XAMPP Setup and Projects

A short environment check prevents installation, folder and service problems from consuming development time. Environment check Check Successful evidence XAMPP opens Control Panel loads Apache runs http://localhost/ opens MySQL runs phpMyAdmin opens Project lo...

PHP and MySQL Foundations

PHP and MySQL

Connect PHP securely to MySQL and implement validated create, read, filter and update operations with PDO.

Connecting PHP to MySQL

PHP and MySQL PHP and MySQL Foundations

A database connection allows PHP to send SQL to MySQL and receive results. Keep the connection in one reusable file. Create the connection file Create includes/db.php: <?php $host = "localhost"; $dbname = "campready_db"; $username = "root"; $password = ""; $d...

Using Prepared Statements

PHP and MySQL PHP and MySQL Foundations

Prepared statements keep user-supplied values separate from SQL instructions. Use them whenever a value comes from a form, URL, session or uploaded file. Unsafe pattern $sql = "SELECT * FROM activities WHERE location = '" . $_GET["location"] . "'"; Concatenati...

Inserting Validated Form Data

PHP and MySQL PHP and MySQL Foundations

An insert should accept input, validate it, store it with a prepared statement and report a useful result. Example form <form method="post"> <label for="activity_name">Activity name</label> <input id="activity_name" name="activity_name" maxlength="100" req...

Selecting and Displaying Records

PHP and MySQL PHP and MySQL Foundations

A useful output begins with a query and ends with accessible, escaped HTML. Select only required fields $stmt = $pdo->query( "SELECT activity_id, activity_name, location, capacity FROM activities ORDER BY activity_name" ); $activities = $stmt->fe...

Filtering and Sorting Records

PHP and MySQL PHP and MySQL Foundations

Filters help users reduce a dataset to relevant records. Sorts place those records in a useful order. Filter with a prepared value $location = trim($_GET["location"] ?? ""); $stmt = $pdo->prepare( "SELECT activity_name, location, capacity FROM activit...

Updating Existing Records

PHP and MySQL PHP and MySQL Foundations

An update changes an existing row. The application must identify the row, validate changes and prevent unintended updates. Load the selected record $id = filter_input(INPUT_GET, "id", FILTER_VALIDATE_INT); if (!$id) { exit("Invalid activity."); } $stmt = $...

Protecting an Admin-Only Data Import Page

PHP and MySQL Login Systems

A role-based system must enforce permissions on the server. Hiding a link is helpful navigation, but it does not protect the page. Store trusted session values at login After verifying the password and retrieving the database user: session_regenerate_id(true);...

Importing CSV into MySQL with PHP

Working with Data

Build a secure administrator-only workflow that validates fictional CSV data and stores acceptable rows in MySQL.

Processing and Presenting Imported Data

Working with Data

Query, process and present stored data as meaningful outputs that respond to user needs and success criteria.

Understanding CSV Data

Working with Data Importing CSV into MySQL with PHP

CSV means comma-separated values. Each line is a record and each position represents a field. match_id,team_name,wins,losses M001,Fictional Falcons,4,1 M002,Sample Sharks,3,2 The first row is a header. Quoted fields may contain commas, so do not process CSV wi...

Designing a MySQL Table from a CSV

Working with Data Importing CSV into MySQL with PHP

Design the destination table from the meaning of the data, not merely its appearance in a spreadsheet. CSV field MySQL type Rule match_id VARCHAR(20) unique and required team_name VARCHAR(100) required wins INT zero or greater losses INT zero or greater CREATE...

Creating an Admin-Only CSV Upload Form

Working with Data Importing CSV into MySQL with PHP

A CSV upload changes stored data and should be restricted to administrators. Apply session and role checks before any output. <?php session_start(); if (!isset($_SESSION["user_id"])) { header("Location: login.php"); exit; } if (($_SESSION["role"] ?? ""...

Validating an Uploaded CSV File

Working with Data Importing CSV into MySQL with PHP

Validate the upload before reading its rows. $file = $_FILES["dataset"] ?? null; $errors = []; if (!$file || $file["error"] !== UPLOAD_ERR_OK) { $errors[] = "Choose a CSV file that uploaded successfully."; } if ($file && $file["size"] > 2 * 1024 * 1024) { ...

Reading CSV Rows with fgetcsv

Working with Data Importing CSV into MySQL with PHP

Use PHP’s CSV parser so quoted commas and escaped values are handled correctly. $handle = fopen($file["tmp_name"], "r"); if ($handle === false) { exit("The uploaded file could not be read."); } $headers = fgetcsv($handle); $expected = ["match_id", "team_na...

Validating CSV Rows

Working with Data Importing CSV into MySQL with PHP

Validate every row before storing it. if (count($row) !== 4) { $rowErrors[] = "Row $rowNumber has the wrong number of fields."; continue; } [$matchId, $teamName, $winsRaw, $lossesRaw] = array_map("trim", $row); $wins = filter_var($winsRaw, FILTER_VALID...