PHP/MySQL web application that streamlines the process of registering, tracking, and reporting on visitors and vehicles entering a guarded facility (campus, office, hostel, etc.). The UI is built on a Bootstrap 4 admin theme and ships with ready-made screens for day-to-day gate operations.
- Dashboard metrics for total, today, and yesterday visitor and vehicle counts plus quick links into detail views.
- Visitor registry with add/edit forms, photo upload, enter/exit timestamps, remarks, search, filters for "inside" versus "exited today", and soft validation for missing date columns.
- Vehicle register with similar CRUD, enter/exit tracking, inline AJAX updates (
vehicle-update.php), and per-row activity logging (storage/logs/vehicle-update.log). - Department and designation masters for maintaining lookup values used throughout visitor records.
- Reports between dates (
bwdates-reports.php) to audit visits over a chosen window. - QR scanning workflow (
scan_page.php) powered by html5-qrcode to fetch visitor details on scan, with hits optionally logged toscan_log. - Account administration: login, forgot/reset password, change password, and profile update for the admin user (
tbladmin).
- PHP 7.4+ with the
mysqliextension - MySQL or MariaDB (configure your own database name during setup)
- Apache or any PHP-capable web server (XAMPP/LAMP/WAMP recommended for local development)
- Bootstrap 4.1, Font Awesome, jQuery, and other UI assets vendored under
vendor/ - Optional online dependency:
html5-qrcode(loaded from CDN inscan_page.php)
css/- Theme stylesheets bundled with the admin templateimages/- Backgrounds and illustrative assetsincludes/- Shared PHP includes (dbconnection.php,header.php,sidebar.php,fetch_data.php)js/- Template JavaScript for Bootstrap, charts, helpersstorage/logs/- Runtime logs (for examplevehicle-update.log)uploads/- Visitor photo uploads (ensure write permission)vendor/- Front-end libraries (Bootstrap, FontAwesome, etc.)*.php- Page controllers (dashboard, forms, reports, API endpoints)README.md
- PHP 7.4 or newer (tested up to PHP 8.2) with
mysqlienabled. - MySQL 5.7 / 8.0 or MariaDB equivalent.
- Composer is not required; dependencies are already vendored.
- Writable
uploads/andstorage/logs/directories for file storage and logging. - Internet access if you plan to use the QR code scanning page (loads
html5-qrcodefrom a CDN).
- Clone or copy the project into your web server's document root (for example
c:\xampp\htdocs\gatepass-main). - Create the database (choose any name you prefer;
gatepass_dbis used here as an example):CREATE DATABASE gatepass_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
- Import schema/data:
- If you already have an export, import it into your chosen database.
- Otherwise, create the tables listed in the Database Overview section manually (the column names are inferred from the codebase).
- Configure database credentials by editing
includes/dbconnection.php:Adjust the host, username, password, and database name to match your environment.$con = mysqli_connect("localhost", "root", "", "your_database_name");
- Ensure writable directories:
On Windows, confirm the IIS/Apache user has modify rights.
chmod -R 775 uploads storage/logs # Linux or macOS example - Start your web server (for example Apache via XAMPP Control Panel) and navigate to
http://localhost/gatepass-main/. - Create an admin account if the database is empty (see below).
| Table | Purpose | Key Columns Used In Code |
|---|---|---|
tbladmin |
Stores the admin account that can log in. | ID, AdminName, UserName, Password (MD5 hash), MobileNumber, Email |
tblvisitor |
Master table for visitor profiles and visit logs. | ID, FullName, rollno, Deptartment, des, MobileNumber, Email, Address, CNIC, photo, EnterDate, ExitDate, remark |
vehicles |
Registered vehicles linked to visitors or employees. | id, fullname, vnumber, EnterDate, ExitDate |
departments |
Department catalog used in visitor forms. | id, dep |
designations |
Designation/role catalog used in visitor forms. | id, designation |
scan_log |
Optional audit trail for QR scans. | id, rollno, created_at (add a timestamp column for better tracing) |
Note: The application defensively adds
EnterDateandExitDatecolumns at runtime if they are missing to avoid fatal errors. It is still best to define them up-front in your schema.
Insert at least one administrator so you can sign in:
INSERT INTO tbladmin (AdminName, UserName, MobileNumber, Email, Password)
VALUES ('Site Admin', 'admin', '03001234567', 'admin@example.com', MD5('ChangeMe123!'));You can later change the password from within the UI (change-password.php).
-
Visitor intake
- Use
visitors-form.php,studententry.php,teacherentry.php, orclass4entry.phpto create new profiles. save_visitor.phphandles photo uploads intouploads/and stores the relative path intblvisitor.photo.visitor-enter.phpandvisitor-exit.phpstamp entry or exit times;visitor-update.phplets you amend dates manually.
- Use
-
Vehicle tracking
- Add vehicles via
addvehicle.php, manage them inmanagevehicle.php. - Inline edit uses AJAX (
vehicle-update.php) and logs every request tostorage/logs/vehicle-update.log. - Entry/exit buttons call
vehicle-enter.phpandvehicle-exit.php.
- Add vehicles via
-
Reports and auditing
bwdates-reports.php->bwdates-reports-details.phpprovides between-dates filtering ontblvisitor.EnterDate.manage-newvisitors.phpandmanagevehicle.phpinclude status filters (All,Currently Inside,Exited Today) plus message banners driven by themsgquery parameter.
-
QR scanning
- Visit
scan_page.php, allow camera access, and scan a code containingtblvisitor.ID. includes/fetch_data.phpreturns JSON used to populate the result panel.- Make sure
scan_logexists if you want to retain scan history (the script attempts to insert into it).
- Visit
- Uploads: Images land in
uploads/. The application will create the folder on demand, but pre-creating it with appropriate permissions is safer. - Logs: Runtime diagnostics append to
storage/logs/vehicle-update.log. You can add more log files as needed; keep the directory writable.
- Error reporting is suppressed across most pages (
error_reporting(0);). Enable it temporarily while debugging:error_reporting(E_ALL); ini_set('display_errors', 1);
- SQL queries are currently composed manually. For production hardening consider parameterised queries (prepared statements) and stronger password hashing (for example
password_hash()). - Front-end libraries live under
vendor/. Replace or upgrade them by dropping in newer versions as required; no build pipeline is involved. scan_page.phpincludes the QR library from a CDN. Bundle it locally if offline access is required.
- Blank pages or redirects back to login: Confirm
$_SESSION['cvmsaid']is being set after login. Sessions requiresession.save_pathto be writable. - "Connection Fail" errors: Verify credentials in
includes/dbconnection.phpand ensure MySQL is running. - Image upload failures: Check
uploads/permissions and PHP'supload_max_filesize/post_max_size. - QR scanner not loading: Ensure the device has a camera and the page is served over HTTP or HTTPS with camera permissions granted.
- Missing columns: The code attempts to auto-add
EnterDateandExitDate, but other columns (for examplerollno,photo) must exist. Revisit the Database Overview table if you see SQL errors.
- Add a
database/folder with a SQL dump for easy bootstrapping. - Replace MD5 password storage with PHP's
password_hash()/password_verify(). - Implement role-based access control if guards or clerks require separate logins.
- Expand reporting (CSV export, vehicle statistics, etc.) as needed.
No explicit license is provided. Treat this project as "all rights reserved" until the authors specify otherwise.