I Was Here – PHP Student Attendance Management System


I Was Here is a simple, free, and open-source PHP Student Attendance Management System. It has zero dependencies on third-party frameworks and is completely built using pure HTML, CSS, Javascript, PHP. This should help developers to quickly build on – No need to learn any additional frameworks, no added script bloating.

 

TABLE OF CONTENTS

Download & Notes How To Use Quick Reference
How To Develop Common Problems

 

 

DOWNLOAD & NOTES

First, here are the download links and a quick “setup guide” for the impatient folks who don’t have the patience to read through everything.

 

DOWNLOAD LINKS

Download I-Was-Here | GitHub | SourceForge

 

LICENSE

I-Was-Here is released under the MIT License. You are free to use it for your own personal and commercial projects, modify it as you see fit. On the condition that there the software is provided “as-is”. There are no warranties provided and “no strings attached”. Code Boxx and the authors are not liable for any claims, damages, or liabilities.

 

REQUIREMENTS

I-Was-Here has not been extensively tested, but it is developed and works on a WAMP8 (Windows Apache MySQL PHP 8) server. Requirements:

  • Apache Mod Rewrite
  • PHP PDO Extension
  • Best to have at least PHP 7

 

INSTALLATION

As for the “installation”… There is no installer, but this should be simple enough:

  1. Create a database and import the core/iwashere.sql file.
  2. In core/Core.php, change the database settings (A2), host (A4), and email (A5) to your own.

That’s all. The default user is “admin@iwh.com” and the password is “123456“. Remember to change it later.

 

 

HOW TO USE

So far so good? Let us now go through a quick crash course on how to use I Was Here.

 

STEP 1) REGISTER TEACHERS & STUDENTS

First, register the teachers and students under the “Users” tab. You can add them one-by-one… But the faster way is to mass import a CSV file with the name, email, and password. For example:

Jon Doe jon@doe.com 123456
Jan Doe jan@doe.com 654321
Jay Doe jay@doe.com 2254567

 

STEP 2) REGISTER COURSES

Next, register your available courses under the “Courses” tab. Same old story, you can do it manually one by one, but importing is faster. This time in the order of course code, course name, description. For example:

MATH Basic Math Basic Mathematics course.
ENG Basic English How to ABC.
SCI Basic Science For kids 5-55.

 

 

STEP 3) ASSIGN STUDENTS TO COURSES

With that, we can now assign students to their respective courses. The painful way is to assign students one by one with their email… But you catch the drift, just importing a whole list of emails is faster. Example:

jon@doe.com
jan@doe.com
jay@doe.com

 

STEP 4) REGISTER CLASSES

Now that all the necessary data is in, register the classes.

 

STEP 5) TAKE ATTENDANCE

Lastly, Captain Obvious, take the attendance of the class.

 

 

QUICK REFERENCE

This section is for the developers, a quick walkthrough of the general system structures.

 

FOLDER STRUCTURE

  • core/ Holds the libraries and API files.
  • pages/ The HTML pages
  • public/ Javascript, CSS, images, whatever public assets.

Yes, there are only 3 folders in the entire system.

 

DATABASE TABLES

users – The teachers and students.
Field Description
user_id The user ID, primary key, auto-increment.
user_name Name of the user.
user_email Email of the user, unique and does not allow duplicates.
user_role Teacher or Student.
user_password Account password.
courses – The available course.
Field Description
course_code The course code, primary key.
course_name Name of the course.
course_desc A short description of the course.
courses_students – Which student is enrolled in which courses.
Field Description
course_code The course code, primary key.
user_id The user ID, primary key.
classes – Classes conducted.
Field Description
class_id The class ID, primary key, auto-increment.
couse_code The course code.
class_date Date and time of the class.
class_desc Short description of the class.
attendance – Attendance records.
Field Description
class_id The class ID, primary key.
user_id The user ID, primary key.
sign_date Timestamp, when the attendance is taken.

 

 

API REQUESTS

There are only 3 sets of API handlers:

  • http://SITE.COM/api/Class Class-related requests.
  • http://SITE.COM/api/Course Course-related requests.
  • http://SITE.COM/api/User User-related requests.

Just do a POST request followed by the required parameters.

  • $_POST['req'] is for open requests, no user verification is required.
  • $_POST['reqS'] for student functions.
  • $_POST['reqT'] for teacher functions.

 

CLASS API REFERENCE & EXAMPLES

ADD OR UPDATE CLASS
reqT : "save"
code : "BIO234" // COURSE CODE
id : 1 // TEACHER IN CHARGE (USER ID)
date : "2077-06-05 12:30:00" // CLASS DATE TIME
desc : "Bio class" // DESCRIPTION (OPTIONAL)
cid : 888 // CLASS ID (ONLY IF EDITING)
DELETE CLASS
reqT : "del"
id : 888 // CLASS ID
UPDATE ATTENDANCE
reqT : "attend"
cid : 888 // CLASS ID
uid : 999 // USER (STUDENT ID)
attend : 1 // 1 FOR PRESENT, 0 FOR ABSENT
time : "2027-06-05 12:34:56" // OPTIONAL, ASSUME NOW IF NOT PROVIDED

 

COURSES API REFERENCE & EXAMPLES

ADD OR UPDATE COURSE
reqT : "save"
code : "BIO123" // COURSE CODE
name : "Advanced Biology" // COURSE NAME
desc : "Human antonomy" // COURSE DESCRIPTION (OPTIONAL)
ocode : "BIO234" // OLD COURSE CODE (ONLY IF EDITING)
DELETE COURSE
reqT : "del"
code : "BIO123" // COURSE CODE
ADD STUDENT TO COURSE
reqT : "stuAdd"
code : "BIO123" // COURSE CODE
email : "jon@doe.com" // STUDENT EMAIL
REMOVE STUDENT FROM COURSE
reqT : "stuDel"
code : "BIO123" // COURSE CODE
id : 888 // STUDENT ID

 

USERS API REFERENCE & EXAMPLES

ADD OR UPDATE USER
reqT : "save"
name : "Jon Doe" // USER NAME
email : "jon@doe.com" // USER EMAIL
pass : "123456" // PASSWORD
role : "S" // S FOR STUDENT, T FOR TEACHER
id : 888 // USER ID (ONLY IF EDITING)
DELETE USER
reqT : "del"
id : 888 // USER ID
LOGIN
req : "login"
email : "jon@doe.com"
pass : "123456"
LOGOUT
req : "logoff"

 

 

DEVELOPING “I WAS HERE”

As simple as it may be, going through the entire system is still going to take some time. So instead of “explaining line-by-line”, here is a condensed version of “how to quickly customize and upgrade”.

P.S. I-Was-Here is actually a variant of Core Boxx. Go ahead and check out that other project of mine if you want to learn more.

 

STEP 1) CREATE/MODIFY DATABASE TABLES

Add your new tables, modify the existing ones.

 

STEP 2) ADD/UPDATE SYSTEM MODULE

Create a core/LIB-Module.php, define class Module, add functions inside. For example, to add a new report module – Create core/LIB-Report.php.

core/LIB-Report.php
class Report {
  function getStudentAttend ($id) {
    return $this->core->fetchAll(
      "SELECT * FROM `attendence` WHERE `user_id`=? ORDER BY `sign_date` DESC",
      [$id]
    );
  }
}

That’s it. The new module can now be loaded via $_CORE->load("Report") and the new function can be accessed via $_CORE->Report->getStudentAttend().

 

STEP 3) ADD/UPDATE API ENDPOINT (OPTIONAL)

Create core/API-Module.php. For example, core/API-Report.php can be accessed at http://site.com/api/Report. How the API work is simple, we just send a $_POST['req'] OR $_POST['reqS'] OR $_POST['reqT] followed by the required parameters.

core/API-Report.php
// (A) TEACHER REQUESTS
$_CORE->load("Report");
if (isset($_POST['reqT'])) { switch ($_POST['reqT']) {
  // (A0) INVALID
  default:
    $_CORE->respond(0, "Invalid request");
    break;
 
  // (A1) GET STUDENT ATTENDANCE
  case "getAttend":
    $records = $_CORE->Report->getStudentAttend($_POST['id']);
    $_CORE->respond(1, "OK", $records);
    break;
}}

That’s all. We can now send $_POST['reqT']="getAttend" and $_POST['id']=123 to http://site.com/api/Report to fetch the report in a JSON-encoded string.

 

STEP 4) ADD/UPDATE HTML CSS JAVASCRIPT

  • Add new pages with pages/PAGE-name.php. For example, pages/PAGE-report.php will be accessed from http://site.com/report.
  • Add new admin pages with pages/ADMIN-name.php. For example, pages/ADMIN-report.php will be accessed from http://site.com/admin/report.
  • Take note – PAGE-name.php can only be accessed by users who are signed in, ADMIN-name.php can only be accessed by teachers.

That’s about it. Just reverse engineer and copy from the existing libraries, API, and pages… You will see the development pattern here.

 

COMMON PROBLEMS & FIXING THEM

I-Was-Here is “not working”? Here are a few of the common problems and how to “fix” them.

 

I FORGOT THE PASSWORD/DELETED ALL ADMIN ACCOUNTS

Create an “account recovery” script to create a new account, or update an existing one.

recover.php
require "core/Core.php";
$_CORE->load("User");
$_CORE->User->save("NAME", "EMAIL", "PASSWORD", "T", OPTIONAL-USER-ID);

Run and delete this afterward…

 

MIGRATED TO A NEW DOMAIN

  • Simply update URL_BASE in core/Core.php.
  • Delete .htaccess, let the system will regenerate a new one.
  • Clear the browser cache to prevent irritating cache redirects.

Done. If you have some extra URL rewrite to add – Go ahead and modify __construct() in core/LIB-Core.php.

 

NOT WORKING. DON’T KNOW WHY.

Update public/common.js section E1 – opt.debug = true. Reload the page and see the error message.

How To Debug Javascript – A Very Simple Guide

How to Debug PHP Code – A Very Simple Guide

6 thoughts on “I Was Here – PHP Student Attendance Management System”

  1. Michele Fioretti

    Helllo , I have error 404 only on export attendance as csv. The remain function already works. Can yo have suggestions ? Thanks in advances.
    Can provide me example api call for register attendance of a student ? Thanks in advances.

    1. 1) Not getting 404 on my test server. The export CSV points to http://YOUR-SITE.COM/admin/export-attend and resolves to pages/ADMIN-export-attend.php as intended.
      2) Page updated, see reference above.

  2. Hi, when I run Iwashere with php -S 127.0.0.1:8000 it works fine but as soon as I upload it redirects to localhost/login and I get a 404 message. I am using 18.04 php ver 7.2.24 Apache2 ver 2.4.29. I cleared the.htaccess file and it didn’t work.

Leave a Comment

Your email address will not be published. Required fields are marked *