We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies. Learn More
contact@techquestworld.com
+919547614783
Premium Article
Published 7 months ago

Build a Complete PHP CRUD App with Bootstrap – No Framework

5 min read
564 views
Build a Complete PHP CRUD App with Bootstrap – No Framework
Photo by Techquestworld
Build a Complete PHP CRUD App with Bootstrap – No Framework
Photo by Techquestworld
Build a Complete PHP CRUD App with Bootstrap – No Framework
Photo by Techquestworld

Looking to build a full web app in PHP without relying on Laravel or CodeIgniter? This step-by-step tutorial shows you how to create a fully functional CRUD app using plain PHP and Bootstrap 5. No frameworks—just clean code, a responsive layout, and a MySQL database.

📌 What You'll Build:

• A record listing table

• A form to add new entries

• Edit & delete functionality

• Database connectivity with MySQL

• Bootstrap UI with alerts and modals


🧱 Prerequisites:

• PHP 7.4+

• MySQL/MariaDB

• A local server (XAMPP, WAMP, or MAMP)

• Basic HTML/CSS/PHP knowledge


🔧 Step 1: Set Up Your Project Structure

/crud-php-bootstrap/

├── config.php

├── index.php

├── create.php

├── update.php

├── delete.php

└── assets/

└── bootstrap.min.css


⚙️ Step 2: Create Your Database Table

CREATE DATABASE crud_app;
USE crud_app;

CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

📄 Step 3: config.php – DB Connection

<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "crud_app";

$conn = new mysqli($host, $user, $pass, $db);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>

📋 Step 4: index.php – Show All Records

<?php include 'config.php'; ?>
<!DOCTYPE html>
<html>
<head>
<title>PHP CRUD</title>
<link rel="stylesheet" href="assets/bootstrap.min.css">
</head>
<body class="container mt-5">
<h2>User List <a href="create.php" class="btn btn-primary float-end">+ Add New</a></h2>
<table class="table table-bordered mt-3">
<thead><tr><th>ID</th><th>Name</th><th>Email</th><th>Actions</th></tr></thead>
<tbody>
<?php
$result = $conn->query("SELECT * FROM users");
while ($row = $result->fetch_assoc()):
?>
<tr>
<td><?= $row['id'] ?></td>
<td><?= $row['name'] ?></td>
<td><?= $row['email'] ?></td>
<td>
<a href="update.php?id=<?= $row['id'] ?>" class="btn btn-warning btn-sm">Edit</a>
<a href="delete.php?id=<?= $row['id'] ?>" onclick="return confirm('Delete?')" class="btn btn-danger btn-sm">Delete</a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</body>
</html>

🆕 Step 5: create.php – Add New User

<?php include 'config.php';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$email = $_POST['email'];
$conn->query("INSERT INTO users (name, email) VALUES ('$name', '$email')");
header("Location: index.php");
}
?>

<form method="POST" class="container mt-5">
<h2>Add User</h2>
<input name="name" class="form-control mb-2" placeholder="Name">
<input name="email" class="form-control mb-2" placeholder="Email">
<button class="btn btn-success">Save</button>
</form>

✏️ Step 6: update.php – Edit User

<?php
include 'config.php';
$id = $_GET['id'];
$user = $conn->query("SELECT * FROM users WHERE id=$id")->fetch_assoc();

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$email = $_POST['email'];
$conn->query("UPDATE users SET name='$name', email='$email' WHERE id=$id");
header("Location: index.php");
}
?>

<form method="POST" class="container mt-5">
<h2>Edit User</h2>
<input name="name" value="<?= $user['name'] ?>" class="form-control mb-2">
<input name="email" value="<?= $user['email'] ?>" class="form-control mb-2">
<button class="btn btn-warning">Update</button>
</form>

🗑️ Step 7: delete.php

<?php
include 'config.php';
$id = $_GET['id'];
$conn->query("DELETE FROM users WHERE id=$id");
header("Location: index.php");
?>

Final Output :

• Fully responsive UI using Bootstrap

• Add/Edit/Delete records

• Simple PHP-only structure, no framework

• Great starter project

Author
TAPAS SAHOO

Developer by Profession, Techie by Heart

A curious mind with a love for writing and technology, dedicated to simplifying web development and programming topics while keeping up with the ever-changing tech landscape.

Discussion (0)

Replying to
Previous Article
2025: The Essential 10 Free AI Tools You Shou...

Next Article
10 High-Income Skills You Can Learn in 30 Day...

Boost your career and productivity with proven strategies, expert tips, and real-world advice—all in...

Related Articles

Simple Contact Form in PHP with Email Functionality – Step-by-Step Guide
PHP
Simple Contact Form in PHP with Email Functionalit...

Build a working contact form using PHP that sends form data via email. A great beginner PHP project...

Modern PHP Newsletter Subscription Form with Stylish Design
PHP
Modern PHP Newsletter Subscription Form with Styli...

A minimal PHP-powered newsletter form to collect email addresses, designed with a clean, modern look...

Simple Feedback Form with PHP Email Support
PHP
Simple Feedback Form with PHP Email Support

Send feedback directly to your inbox using this beautifully designed PHP form.

Pessimistic vs Optimistic Locking in Laravel: A Developers Deep‑Dive
Pessimistic vs Optimistic Locking in Laravel: A De...

Learn how to safeguard your Laravel applications from race conditions by applying the right concurre...