Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hospital System (PHP/MySQL)

Modernized PHP/MySQL hospital management demo with secure uploads, prepared statements, reports, and basic authentication.

Features

  • Patients: add and manage patient records
  • Doctors: manage doctors (UI scaffold present)
  • HR: upload contract PDFs, store metadata, and track staff
  • Lab: tests catalog, inventory usage, issued tests, and follow-ups
  • Finance: fees configuration and accounts (in/out) entries
  • Reports: overview dashboard, accounts report, lab usage report, printable fees report
  • File uploads: hardened PDF-only uploads with random filenames and secure download endpoint
  • Security: centralized DB config via env, prepared statements across pages, CSRF-ready structure
  • Auth: users table with password hashing, session login/logout, admin seeding, admin-only Users page

Quick Start

  1. Requirements
  • PHP 8.x with mysqli, fileinfo extensions enabled
  • MySQL 5.7+ / MariaDB 10+
  1. Database
  • Create a database (default: moala_hospital).
  • Import schema/data from database/ (.sql files) if needed.
  1. Configuration (Environment Variables) Create a .env file in the project root (same folder as this README) with:
DB_HOST=127.0.0.1
DB_PORT=3306
DB_NAME=moala_hospital
DB_USER=root
DB_PASS=your_password
# Optional (macOS/Homebrew socket path example):
# DB_SOCKET=/tmp/mysql.sock

Notes:

  • If .env is missing, the app falls back to DB_HOST=127.0.0.1, DB_NAME=moala_hospital, DB_USER=root, DB_PASS=oracleoracle (change this in production).
  • You can override any value via real environment variables as well.
  1. Run locally
  • Serve the code/ directory with PHP or a local web server (Apache/Nginx).
  • Example (PHP dev server):
    • cd code
    • php -S 127.0.0.1:8080
  • Open http://127.0.0.1:8080/index.php
  1. Login
  • A default admin user is auto-created on first visit to the sign-in page:
    • Username: admin
    • Password: admin
  • Change this immediately after logging in.

Project Structure (key paths)

  • code/basefiles/ – layout, connection, auth helpers, components
  • code/*.php – pages (patients, hr, lab, reports, etc.)
  • code/uploads/ – uploaded PDFs (gitignored)
  • database/ – SQL dumps and migration helper

Security & Hardening

  • Do NOT commit .env with real credentials.
  • Change the fallback DB password in code/basefiles/connection.php or use .env.
  • Uploaded files are stored under code/uploads/ and served via code/filedownload.php?id=....
  • Most raw SQL has been migrated to prepared statements; new code should follow the same.

Common Issues

  • MySQL socket on macOS: set DB_HOST=127.0.0.1 or specify DB_SOCKET=/tmp/mysql.sock in .env.
  • Headers already sent: ensure redirects occur before any HTML output (login flow already fixed).

Roadmap / Ideas

  • Role-based permissions per page/action
  • CSRF tokens on all forms
  • Pagination and search on long lists
  • Unit/integration tests

License

This project is provided as-is for educational/demo purposes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages