Employee Management System – PHP + MySQL Based Web App

📌 Project Title:

Employee Management System


📚 Technology Stack:

Frontend: HTML, CSS (Bootstrap)

Backend: PHP

Database: MySQL

Tools Used: XAMPP / KSWeb / Localhost (for testing), VS Code


🛠️ Modules Included:

  1. Login System (Admin Only)
  2. Dashboard
  3. Add New Employee
  4. Edit Employee Details
  5. Delete Employee
  6. Employee List View with Table
  7. Logout System

📁 Database Tables:

users: Stores login credentials (admin only)

employees: Stores employee information


✅ Features:

Secure login with session-based authentication

CRUD operations on employee data

Clean UI with table view

User-friendly forms

Database-driven

Fully local-host compatible

Works on mobile via responsive Bootstrap


🔐 Admin Login Credentials (Default):

Username: admin

Password: admin123
(Password is stored using MD5 encryption)


🌐 How to Run:

  1. Install XAMPP or KSWeb on your system/mobile
  2. Copy project folder into htdocs (or KSWeb root)
  3. Import employee_system.sql in phpMyAdmin
  4. Open browser and visit:
    http://localhost/project_folder/login.php
  5. Login and start managing employees

📷 Screenshots:

(Add these manually in your report or presentation)

Login Page

Dashboard

Employee Table

Add/Edit Employee Form


🔄 Future Improvements (Optional):

Add pagination or search filters

Export employee data to Excel/PDF

Add profile pictures or file uploads

Create multiple user roles (e.g., HR, Manager)

Host live using a free PHP hosting service like InfinityFree

✅ 1. db.php – Database Connection

<?php$conn = new mysqli("localhost", "root", "", "employee_system");if ($conn->connect_error) {    die("Connection failed: " . $conn->connect_error);}?>

✅ 2. login.php

<?php
session_start();
include 'db.php';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $user = $_POST['username'];
    $pass = md5($_POST['password']);

    $sql = "SELECT * FROM users WHERE username='$user' AND password='$pass'";
    $res = $conn->query($sql);

    if ($res->num_rows == 1) {
        $_SESSION['username'] = $user;
        header("Location: index.php");
    } else {
        $error = "Invalid Credentials";
    }
}
?>
<!DOCTYPE html>
<html>
<head><title>Login</title></head>
<body>
<h2>Login</h2>
<form method="post">
    <input type="text" name="username" placeholder="Username" required><br>
    <input type="password" name="password" placeholder="Password" required><br>
    <button type="submit">Login</button>
</form>
<?php if(isset($error)) echo "<p>$error</p>"; ?>
</body>
</html>

✅ 3. logout.php

<?php
session_start();
session_destroy();
header("Location: login.php");
?>

✅ 4. index.php – Dashboard

<?phpsession_start();if (!isset($_SESSION['username'])) {    header("Location: login.php");    exit;}?><!DOCTYPE html><html><head><title>Dashboard</title></head><body><h2>Welcome, <?php echo $_SESSION['username']; ?>!</h2><p><a href="employees.php">Manage Employees</a></p><p><a href="logout.php">Logout</a></p></body></html>

✅ 5. employees.php

<?phpsession_start();include 'db.php';if (!isset($_SESSION['username'])) {    header("Location: login.php");    exit;}$res = $conn->query("SELECT * FROM employees");?><!DOCTYPE html><html><head><title>Employees</title></head><body><h2>Employee List</h2><a href="add_employee.php">Add Employee</a> | <a href="index.php">Dashboard</a><br><br><table border="1"><tr><th>Name</th><th>Email</th><th>Phone</th><th>Position</th><th>Action</th></tr><?php while ($row = $res->fetch_assoc()): ?><tr>  <td><?= $row['name'] ?></td>  <td><?= $row['email'] ?></td>  <td><?= $row['phone'] ?></td>  <td><?= $row['position'] ?></td>  <td>    <a href="edit_employee.php?id=<?= $row['id'] ?>">Edit</a> |    <a href="delete_employee.php?id=<?= $row['id'] ?>" onclick="return confirm('Delete?')">Delete</a>  </td></tr><?php endwhile; ?></table></body></html>

✅ 6. add_employee.php

<?phpinclude 'db.php';if ($_SERVER['REQUEST_METHOD'] == 'POST') {    $stmt = $conn->prepare("INSERT INTO employees (name, email, phone, position) VALUES (?, ?, ?, ?)");    $stmt->bind_param("ssss", $_POST['name'], $_POST['email'], $_POST['phone'], $_POST['position']);    $stmt->execute();    header("Location: employees.php");}?><form method="post">    <h2>Add Employee</h2>    <input name="name" placeholder="Name" required><br>    <input name="email" placeholder="Email" required><br>    <input name="phone" placeholder="Phone" required><br>    <input name="position" placeholder="Position" required><br>    <button type="submit">Save</button></form>

✅ 7. edit_employee.php

<?phpinclude 'db.php';$id = $_GET['id'];if ($_SERVER['REQUEST_METHOD'] == 'POST') {    $stmt = $conn->prepare("UPDATE employees SET name=?, email=?, phone=?, position=? WHERE id=?");    $stmt->bind_param("ssssi", $_POST['name'], $_POST['email'], $_POST['phone'], $_POST['position'], $id);    $stmt->execute();    header("Location: employees.php");}$res = $conn->query("SELECT * FROM employees WHERE id=$id");$data = $res->fetch_assoc();?><form method="post">    <h2>Edit Employee</h2>    <input name="name" value="<?= $data['name'] ?>" required><br>    <input name="email" value="<?= $data['email'] ?>" required><br>    <input name="phone" value="<?= $data['phone'] ?>" required><br>    <input name="position" value="<?= $data['position'] ?>" required><br>    <button type="submit">Update</button></form>

✅ 8. delete_employee.php

<?phpinclude 'db.php';$id = $_GET['id'];$conn->query("DELETE FROM employees WHERE id=$id");header("Location: employees.php");?>

✅ 9. MySQL Database SQL Dump

CREATE DATABASE employee_system;USE employee_system;CREATE TABLE users (  id INT AUTO_INCREMENT PRIMARY KEY,  username VARCHAR(50) UNIQUE,  password VARCHAR(255));INSERT INTO users (username, password)VALUES ('admin', MD5('admin123'));CREATE TABLE employees (  id INT AUTO_INCREMENT PRIMARY KEY,  name VARCHAR(100),  email VARCHAR(100),  phone VARCHAR(15),  position VARCHAR(100),  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP);

Leave a Reply

Your email address will not be published. Required fields are marked *