PHP + MySQL + CSS CRUD (Procedural)
Lesson 6: Final Polishing & Deployment
๐ Introduction
In this final lesson, students will polish the Student Manager CRUD App by improving the UI, adding basic validation, and preparing the project for deployment on a live server such as cPanel. This lesson focuses on making the application feel professional and ready for real-world use.
๐จ Step 1: Add a Navigation Bar
A simple Bulma navbar helps users navigate between pages. Add this to the top of
index.php, create.php, and edit.php.
<nav class="navbar is-dark">
<div class="navbar-brand">
<a class="navbar-item" href="index.php">Student Manager</a>
</div>
</nav>
This gives the app a consistent header across all pages.
โ Step 2: Add Flash Messages
Flash messages help users understand what actions were successful. We use PHP sessions to display messages after redirects.
session_start();
$_SESSION['message'] = "Student added successfully!";
header("Location: index.php");
exit;
Then display the message at the top of index.php:
<div class="notification is-success">
= $_SESSION['message']; ?>
</div>
๐ก๏ธ Step 3: Add Basic Input Validation
Before inserting or updating data, validate the inputs:
- Ensure fields are not empty
- Ensure email is valid
- Ensure phone number has a minimum length
if(empty($name) || empty($email) || empty($phone)){
$error = "All fields are required.";
}
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$error = "Invalid email format.";
}
Display errors using Bulma:
<div class="notification is-danger">= $error; ?></div>
๐ Step 4: Prepare for Deployment
To deploy the app on cPanel or any hosting platform:
- Upload all project files to the
public_htmldirectory. - Create a MySQL database in cPanel.
- Import your local database using phpMyAdmin.
- Update
db.phpwith live server credentials.
$host = "localhost";
$user = "your_cpanel_username";
$pass = "your_cpanel_password";
$db = "your_database_name";
Once updated, your CRUD app will run online.
๐ Final Thoughts
Congratulations! You have completed the full CRUD cycle using PHP, MySQL, MySQLi procedural programming, and Bulma CSS. You now have a fully functional Student Manager App that can be deployed and expanded with additional features such as search, pagination, authentication, and more.
Edit the panels below and press Run to preview. Nothing you type here is saved โ refreshing the page restores the original starter code.