AttendTrack – Attendance Management System
A full-stack PHP attendance management app with GPS check-in, selfie capture, overtime tracking, and admin reporting. Deployed on Vercel with Vercel Postgres (Neon).
https://absencsm.vercel.app
vercel-app/
├── vercel.json ← Vercel routing config
├── api/ ← All PHP files (serverless functions)
│ ├── config.php ← DB connection, sessions, auth helpers
│ ├── functions.php ← All app functions
│ ├── index.php ← Login page
│ ├── dashboard.php ← User attendance panel
│ ├── register.php ← New account registration
│ ├── logout.php ← Session destroy + redirect
│ ├── profile.php ← Edit username / password / photo
│ ├── forgot-password.php ← Token-based password reset
│ ├── install.php ← One-click DB table installer
│ ├── attendance-action.php ← JSON API for check-in/out
│ ├── admin/
│ │ ├── index.php ← Admin dashboard (Chart.js)
│ │ ├── users.php ← User CRUD + work schedule
│ │ └── reports.php ← Reports + CSV / Excel export
│ └── includes/
│ └── nav.php ← Shared sidebar + topbar
└── public/
└── assets/
├── css/style.css ← Full stylesheet (responsive)
└── logo.svg ← App logo
Layer
Technology
Backend
PHP 8.2 (Vercel serverless via vercel-php@0.7.2)
Database
PostgreSQL (Vercel Postgres / Neon)
Frontend
Vanilla JS + Chart.js
Hosting
Vercel
Auth
PHP sessions stored in Postgres
Styling
Custom CSS (DM Sans + DM Mono)
Table
Description
users
Employees and admins
attendance
Check-in/out records per day
password_resets
Password reset tokens
php_sessions
Server-side session storage (required for Vercel)
Column
Type
Notes
id
SERIAL
Primary key
username
VARCHAR(30)
Unique
email
VARCHAR(100)
Unique
password
VARCHAR(255)
bcrypt hashed
role
VARCHAR(10)
user or admin
work_start
TIME
Scheduled start time
work_end
TIME
Scheduled end time
is_active
SMALLINT
1 = active, 0 = disabled
Column
Type
Notes
user_id
INT
FK → users.id
work_date
DATE
Unique per user per day
checkin_time
TIME
Regular check-in
checkin_lat/lng
DECIMAL
GPS coordinates
checkin_photo
VARCHAR
Saved filename
ot_checkin_time
TIME
Overtime check-in
status
VARCHAR
present, absent, leave, holiday
1. Clone and push to GitHub
git init
git add .
git commit -m " initial commit"
git remote add origin https://github.com/yourname/attendtrack.git
git push -u origin main
Go to vercel.com → Add New Project
Import your GitHub repo
Vercel auto-detects vercel.json — click Deploy
Vercel Dashboard → Storage → Create Database → Postgres
Connect it to your project
Environment variables (PGHOST, PGDATABASE, etc.) are injected automatically
4. Run the database schema
Vercel Dashboard → Storage → your DB → Query tab
Paste and run schema_postgres.sql
Role
Username
Password
Admin
admin
Admin@123
User
john_doe
User@123
User
jane_smith
User@123
User
ali_rahman
User@123
User
siti_nurhaliza
User@123
User
budi_santoso
User@123
⚠️ Change all passwords after first login.
🔐 Login / Register / Forgot Password
📍 GPS-verified Check-In & Check-Out
📸 Selfie photo at every check-in
⏱️ Overtime Check-In & Check-Out
🕐 Live clock display
👤 Edit profile, change password, upload photo
📊 Dashboard with Chart.js weekly trend
👥 User Management (create, edit, delete, set work schedule)
📑 Attendance Reports with filters
📥 Export to CSV and Excel
🔒 Role-based access control
URL
Page
/
Login
/dashboard
User dashboard
/register
Register
/profile
My profile
/forgot-password
Password reset
/logout
Logout
/admin/index
Admin dashboard
/admin/users
User management
/admin/reports
Reports & export
/api/attendance-action
Check-in/out API (POST)
All settings are in api/config.php:
define ('APP_NAME ' , 'AttendTrack ' );
define ('SESSION_TIMEOUT ' , 3600 ); // 1 hour
define ('TIMEZONE ' , 'Asia/Jakarta ' );
Database credentials are read from Vercel environment variables automatically:
$ host = $ _ENV ['PGHOST ' ];
$ dbname = $ _ENV ['PGDATABASE ' ];
$ user = $ _ENV ['PGUSER ' ];
$ password = $ _ENV ['PGPASSWORD ' ];
Issue
Reason
Workaround
Photo uploads are temporary
Vercel filesystem is read-only (uses /tmp)
Integrate Cloudinary or AWS S3
Cold starts
Vercel spins up containers on demand
Normal for serverless — first load may be slow
Sessions stored in DB
Vercel containers don't share /tmp
Already implemented via php_sessions table
# Requires PHP 8.x + PostgreSQL
php -S localhost:8000 -t api/
# Or use Laravel Valet / XAMPP with a local Postgres DB
# Update config.php with local DB credentials
MIT — free to use and modify.