PHP : Work Request Management System

In today's fast-paced business environment, managing work requests efficiently is crucial for team productivity. While there are many enterprise solutions available, sometimes a lightweight, file-based system is all you need - especially for teams or specific departments.

The Solution: A Text-Based Work Request System

This system allows anyone to submit work requests while restricting the approval/denial functionality to authorized administrators. The entire application is built with PHP and runs on any web server with PHP support.

Key features include:

No database required - all data is stored in a text file
Password-protected admin actions
Read-only mode for non-administrators
Color-coded status indicators (green for approved, red for declined)
Mobile-friendly responsive design
Easy deployment and minimal server requirements

Initial State - Password Protected:

When someone first visits the page, they'll see a password field and two buttons:

"Login as Admin" button (requires password)
"Read Only" button (no password needed)

In Read Only mode, the approve/decline buttons are visible but disabled (grayed out)

Admin Mode:

After entering the correct password, the user enters "Admin Mode"
A confirmation message appears at the top with a logout option
Approve/Decline buttons become functional
The admin status persists until logout (using PHP sessions)

Security Features:

Password is stored in the PHP file (set to "admin123" by default - you should change this)
The approve/decline actions are server-side validated to prevent unauthorized actions
Session management handles login state properly

Visual Tour of the Application

Let's see how the application looks and functions before diving into the implementation.

Read-Only Mode (Default View)


When a user first visits the application, they see the login form at the top, the list of current work items in the middle, and the form to add new work items at the bottom. In this view, the approve/decline buttons are visible but disabled (grayed out).

Admin Mode (After Authentication)


After entering the correct password, the user enters "Admin Mode" where they can approve or decline pending requests. A confirmation message appears at the top with a logout option.

Color-Coded Status Indicators


Work items are color-coded based on their status:

  1. White background for pending items
  2. Green background for approved items
  3. Red background for declined items

Server Requirements

Web server (Apache, Nginx, etc.)
PHP 7.0 or higher
Write permissions for the directory where the script is located

Installation

sudo apt update
sudo apt install apache2 php libapache2-mod-php

Start the Apache service:

sudo systemctl start apache2

Create the PHP file:

Save the code as index.php in Apache's web directory:

sudo nano /var/www/html/index.php

Set proper permissions:

sudo chown www-data:www-data /var/www/html/index.php
sudo chmod 644 /var/www/html/index.php
sudo chmod 777 /var/www/html/  # This gives write permission for the work_items.txt file

Access the application by opening a browser and navigating to:

http://<server_ip>/index.php

Previous Post Next Post

نموذج الاتصال