FreeBeginnerPHP 8.0+v2.0

PHP CRUD Application

A complete database management interface with create, read, update, and delete operations. Includes search, pagination, column sorting, data validation, and CSV export. Perfect for admin panels and back-office tools.

Overview

CRUD operations form the backbone of nearly every web application. This script provides a clean, reusable implementation that you can adapt to any database table. It uses PDO with prepared statements for secure database access and includes a responsive HTML interface that works on desktop and mobile devices.

The architecture follows a simple MVC-like pattern with separated concerns. Database queries are handled through a lightweight repository class, making it easy to swap tables or add new entities. The front-end uses vanilla HTML and CSS with no JavaScript framework dependencies.

Key Features

  • Create records with validated form input
  • Read with pagination and configurable page size
  • Update records with inline or modal editing
  • Delete with confirmation dialog
  • Column sorting (ascending and descending)
  • Full-text search across multiple fields
  • CSV and Excel data export
  • Bulk delete for multiple records
  • Flash messages for success and error states
  • Responsive table layout for mobile
  • PDO prepared statements throughout
  • CSRF protection on all write operations

Code Example

The repository pattern keeps database logic clean and testable:

class UserRepository { public function __construct( private PDO $pdo ) {} public function findPaginated( int $page = 1, int $perPage = 20, string $search = '' ): array { $offset = ($page - 1) * $perPage; $sql = 'SELECT * FROM users'; if ($search) { $sql .= ' WHERE name LIKE ? OR email LIKE ?'; } $sql .= ' LIMIT ? OFFSET ?'; $stmt = $this->pdo->prepare($sql); $stmt->execute($params); return $stmt->fetchAll(); } }

Installation Steps

  1. Download and extract the script files to your web server
  2. Create a new MySQL database or use an existing one
  3. Import schema.sql to create the example table structure
  4. Edit config.php with your database host, name, user, and password
  5. Navigate to the script URL in your browser to see the interface
  6. Customize the table columns and validation rules in the entity configuration file

Customization Guide

Adapting the CRUD script to your own database tables is straightforward. The entity configuration file defines which table to use, which columns to display, the form field types for each column, validation rules, and which columns are searchable and sortable. Simply copy the example configuration, change the table name and column definitions, and you have a fully working management interface for any table.

The HTML templates use simple PHP includes with no template engine, so you can style them however you like. The default interface uses the included CSS for a clean, professional look, but every element has semantic class names for easy restyling.

Server Requirements

RequirementMinimumRecommended
PHP Version8.08.2+
DatabaseMySQL 5.7 / MariaDB 10.3MySQL 8.0+
PHP ExtensionsPDO, pdo_mysql+ mbstring
Web ServerApache / NginxAny

Use Cases

This CRUD script is ideal for building admin dashboards, content management back-ends, inventory tracking systems, customer databases, employee directories, product catalogs, and any application where users need to manage database records through a web interface. The modular design means you can manage multiple tables from a single installation.