A lightweight, modern PHP-based web application for finding police station phone numbers across Ghana. Features a sleek design with light/dark themes, responsive layout, and easy-to-use search functionality.
- π Fast Search: Search police stations by town or region name
- π± Mobile-Friendly: Fully responsive design for all devices
- π Theme Toggle: Beautiful light and dark modes with smooth transitions
- π Click-to-Call: Direct calling on mobile devices
- π Copy Numbers: One-click copy to clipboard functionality
- β‘ Real-time Search: Debounced search with instant results
- π Secure Login: Password-protected admin access
- β Add Stations: Easy form to add new police stations
- βοΈ Edit Stations: Update existing station information
- ποΈ Delete Stations: Remove outdated entries
- π Statistics Dashboard: View total stations, regions, and towns
- Raw PHP (no frameworks) for maximum performance
- MySQL database with indexed searches
- Clean, modern UI with CSS animations
- Vanilla JavaScript (no dependencies)
- Secure input sanitization
- Session-based authentication
- XAMPP (or any LAMP/WAMP stack)
- PHP 7.4+
- MySQL 5.7+
- Modern web browser
-
Clone or Download this project to your XAMPP htdocs folder:
c:\xampp\htdocs\policedirectory -
Start XAMPP Services:
- Start Apache
- Start MySQL
-
Create Database:
- Open phpMyAdmin:
http://localhost/phpmyadmin - Click "Import" tab
- Select
database.sqlfile from the project root - Click "Go" to import
OR run the SQL manually:
- Create a new database named
police_directory - Import the
database.sqlfile
- Open phpMyAdmin:
-
Configure Database (if needed):
- Open
config.php - Update database credentials if different from defaults:
define('DB_HOST', 'localhost'); define('DB_USER', 'root'); define('DB_PASS', ''); define('DB_NAME', 'police_directory');
- Open
-
Access the Application:
- Public Site:
http://localhost/policedirectory/ - Admin Panel:
http://localhost/policedirectory/admin/login.php
- Public Site:
Username: admin
Password: admin123
policedirectory/
βββ admin/ # Admin panel files
β βββ login.php # Admin login page
β βββ dashboard.php # Admin dashboard
β βββ add_station.php # Add new station
β βββ edit_station.php # Edit station
β βββ logout.php # Logout handler
βββ api/ # API endpoints
β βββ search.php # Search API
βββ assets/ # Static assets
β βββ css/
β β βββ style.css # Main styles
β β βββ admin.css # Admin styles
β βββ js/
β βββ app.js # Main JavaScript
βββ config.php # Database configuration
βββ database.sql # Database schema & sample data
βββ index.php # Main search page
βββ README.md # This file
- Type-ahead search with 300ms debounce
- Searches both town and region names
- Minimum 2 characters required
- Results display instantly
- Quick search buttons for popular locations
- Automatic theme persistence using localStorage
- Smooth transitions between themes
- CSS variables for easy customization
- Optimized for readability in both modes
- Clean, modern dashboard
- Statistics cards showing key metrics
- Full CRUD operations for police stations
- Responsive data table
- Form validation
- Success/error notifications
- Touch-friendly interface
- Click-to-call functionality
- Optimized button sizes
- Responsive grid layouts
- Smooth animations
Edit admin/add_station.php and admin/edit_station.php to add more regions to the dropdown:
<option value="Your Region">Your Region</option>Edit CSS variables in assets/css/style.css:
:root {
--accent-primary: #3b82f6; /* Change primary color */
--accent-secondary: #06b6d4; /* Change secondary color */
}Update config.php with your database settings:
define('DB_HOST', 'your_host');
define('DB_USER', 'your_username');
define('DB_PASS', 'your_password');
define('DB_NAME', 'your_database');- SQL Injection Protection: Prepared statements for all queries
- XSS Prevention: HTML entity encoding for all output
- Session Security: HTTP-only cookies, secure session handling
- Password Hashing: bcrypt for admin passwords
- Input Sanitization: All user inputs are sanitized
- CSRF Protection: Session-based authentication
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key |
| station_name | VARCHAR(255) | Name of police station |
| town | VARCHAR(100) | Town name |
| region | VARCHAR(100) | Region name |
| phone_number | VARCHAR(50) | Contact number |
| created_at | TIMESTAMP | Creation timestamp |
| updated_at | TIMESTAMP | Last update timestamp |
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key |
| username | VARCHAR(50) | Admin username |
| password_hash | VARCHAR(255) | Hashed password |
| created_at | TIMESTAMP | Creation timestamp |
- β Chrome (latest)
- β Firefox (latest)
- β Safari (latest)
- β Edge (latest)
- β Mobile browsers (iOS Safari, Chrome Mobile)
- Fast Search: < 1 second response time
- Indexed Database: Optimized queries with indexes
- Minimal Dependencies: No external libraries
- Lightweight: Total size < 500KB
- Cached Theme: Instant theme switching
- Type town or region name in the search box
- Results appear automatically as you type
- Click "Call" to dial on mobile devices
- Click "Copy" to copy number to clipboard
- Use quick search buttons for popular locations
- Toggle theme with button in top-right corner
- Login to admin panel
- View statistics on dashboard
- Add new stations with the "Add New Station" button
- Edit stations by clicking "Edit" in the table
- Delete stations with confirmation prompt
- Always logout when finished
- Check if MySQL is running in XAMPP
- Verify database credentials in
config.php - Ensure
police_directorydatabase exists
- Check browser console for JavaScript errors
- Verify
api/search.phpis accessible - Check database has data in
stationstable
- Verify default credentials: admin / admin123
- Check
admin_userstable exists - Clear browser cache and cookies
- Enable localStorage in browser settings
- Check browser console for errors
- Try different browser
- Auto-suggest dropdown for search
- Map integration showing station locations
- Multi-language support (English, Twi, Ga, etc.)
- Export stations to CSV/PDF
- Advanced filtering (by region, distance)
- User feedback/rating system
- SMS integration for emergency contacts
- API for third-party integrations
This project is open source and available under the MIT License.
- PHP 7.4 or higher
- MySQL 5.7 or higher
- Apache web server
- Install XAMPP
- Clone repository to htdocs
- Import database
- Start Apache and MySQL
- Access via localhost
Contributions are welcome! Please feel free to submit a Pull Request.
For issues, questions, or suggestions:
- Open an issue on GitHub
- Contact the development team
- Icons: Lucide Icons (inline SVG)
- Fonts: System fonts for best performance
- Inspiration: Modern web design principles
Built with β€οΈ for Ghana π¬π
Version: 1.0.0
Last Updated: 2025
Status: Production Ready β