Skip to main content
Manage student accounts, profiles, and attendance QR codes within the QR Attendance System.

Student Registration

Endpoint: register.php Method: POST Description: Creates a new student account and generates a unique QR code for attendance tracking.

Request Parameters

user_type
string
required
Must be set to student
student_id
string
required
Unique student identifier. Can be any numeric format.
name
string
required
Student’s full name
email
email
required
Valid email address for account recovery
password
string
required
Account password (minimum 8 characters)
confirm_password
string
required
Password confirmation (must match password)

Registration Process

  1. Validation:
    • Verify passwords match
    • Check if student_id already exists
  2. Database Insertion:
    INSERT INTO students (student_id, name, email, password, qr_code) 
    VALUES (?, ?, ?, ?, ?)
    
  3. QR Code Generation:
    • QR data contains the student_id
    • Generated using QRCode.js library
    • Displayed immediately after successful registration

Response Examples

Success:
<div class="success-message">Student registration successful! Your QR code is ready.</div>
The system generates a QR code using:
new QRCode(document.getElementById("qrcode"), {
    text: "12345",  // student_id
    width: 128,
    height: 128,
    colorDark: "#4361ee",
    colorLight: "#ffffff"
});
Errors:
  • “Passwords do not match”
  • “Student ID already exists”
  • “Registration failed: [database error]”
The QR code contains only the student_id and is stored in the database for reference. Students use this QR code to mark their attendance.

Student Profile Management

Page: student_dashboard.php Authentication: Required (student session) Students can view and update their profile information through the dashboard.

View Profile Information

Database Query:
SELECT * FROM students WHERE id = ?

Response Fields

student_id
string
Unique student identifier
name
string
Student’s full name
email
string
Registered email address
qr_code
string
QR code data (typically the student_id)

Update Email Address

Endpoint: student_dashboard.php Method: POST Authentication: Student session required

Request Parameters

update_email
string
required
Action identifier (set to any value)
new_email
email
required
New email address

Process Flow

  1. Validation:
    • Check if email is already in use by another student
    SELECT * FROM students WHERE email = ? AND id != ?
    
  2. Update Database:
    UPDATE students SET email = ? WHERE id = ?
    

Response Messages

Success:
<div class="alert alert-success">Email updated successfully!</div>
Error:
<div class="alert alert-danger">Email already in use by another account</div>

Change Password

Endpoint: student_dashboard.php Method: POST Authentication: Student session required

Request Parameters

change_password
string
required
Action identifier (set to any value)
current_password
string
required
Current account password for verification
new_password
string
required
New password (minimum 6 characters)
confirm_password
string
required
Must match new_password

Validation Steps

  1. Password Match: Verify new_password === confirm_password
  2. Current Password Verification:
    $stmt = $pdo->prepare("SELECT password FROM students WHERE id = ?");
    $stmt->execute([$student_id]);
    $user = $stmt->fetch();
    
    if (password_verify($current_password, $user['password'])) {
        // Proceed with update
    }
    
  3. Update Password:
    $hashed_password = password_hash($new_password, PASSWORD_DEFAULT);
    $stmt = $pdo->prepare("UPDATE students SET password = ? WHERE id = ?");
    $stmt->execute([$hashed_password, $student_id]);
    

Response Messages

Success:
<div class="alert alert-success">Password changed successfully!</div>
Errors:
  • “New passwords do not match”
  • “Current password is incorrect”
The current password must be verified before allowing password changes to prevent unauthorized modifications.

QR Code Display

Page: student_dashboard.php Section: Dashboard tab

QR Code Generation

The QR code is dynamically generated on the student dashboard using JavaScript:
new QRCode(document.getElementById("qrcode"), {
    text: "<?php echo $student['student_id']; ?>",
    width: 128,
    height: 128
});

QR Code Data Format

text
string
Contains the student_id (e.g., “12345”)
width
number
QR code width in pixels (default: 128)
height
number
QR code height in pixels (default: 128)

Usage

  1. Student displays QR code on screen
  2. Teacher scans QR code using scanner interface
  3. System processes attendance based on scanned student_id
The QR code is displayed prominently in the student dashboard and can be shown to teachers during class for attendance marking.

View Class Enrollment

Query: Get student’s enrolled class
SELECT c.id as class_id, c.name as class_name, t.name as teacher_name 
FROM class_students cs
JOIN classes c ON cs.class_id = c.id
JOIN teachers t ON c.teacher_id = t.teacher_id
WHERE cs.student_id = ?

Response Fields

class_id
integer
Unique class identifier
class_name
string
Name of the enrolled class
teacher_name
string
Name of the class teacher
Students can only be enrolled in one class per teacher, but can be in multiple classes from different teachers.

View Class Schedule

Query: Get schedule for enrolled class
SELECT *, 
CASE day_of_week 
    WHEN 1 THEN 'Sunday'
    WHEN 2 THEN 'Monday'
    WHEN 3 THEN 'Tuesday'
    WHEN 4 THEN 'Wednesday'
    WHEN 5 THEN 'Thursday'
    WHEN 6 THEN 'Friday'
    WHEN 7 THEN 'Saturday'
END as day_name
FROM class_schedules 
WHERE class_id = ?
ORDER BY day_of_week

Response Fields

day_of_week
integer
Day number (1=Sunday, 7=Saturday)
day_name
string
Human-readable day name
start_time
time
Class start time (HH:MM:SS format)
grace_period
integer
Minutes after start_time before student is marked late

Displayed Information

  • Class Name: From enrolled class
  • Start Time: Formatted as “h:i A” (e.g., 09:00 AM)
  • Late After: Calculated as start_time + grace_period minutes
Example display:
Monday
Class: Computer Science 101
Start Time: 09:00 AM
Late After: 09:15 AM

View Attendance Statistics

Query: Calculate student attendance metrics
SELECT 
    COUNT(*) as total_attendance,
    COUNT(DISTINCT DATE(date)) as days_attended,
    MAX(date) as last_attendance
FROM attendance 
WHERE student_id = ?

Response Fields

total_attendance
integer
Total number of attendance records (check-ins)
days_attended
integer
Number of unique days with attendance
last_attendance
date
Most recent attendance date

View Attendance History

Query: Get recent attendance records
SELECT a.*, c.name as class_name, t.name as teacher_name
FROM attendance a
LEFT JOIN classes c ON a.class_id = c.id
LEFT JOIN teachers t ON c.teacher_id = t.teacher_id
WHERE a.student_id = ? 
ORDER BY a.date DESC, a.time DESC 
LIMIT 10

Response Fields

date
date
Attendance date
time
time
Check-in time
status
string
Attendance status: on-time, late, or absent
class_name
string
Name of the class
teacher_name
string
Name of the teacher who recorded attendance

Status Display

if ($status == 'on-time') {
    echo "<span class='status-badge on-time'>On Time</span>";
} elseif ($status == 'late') {
    echo "<span class='status-badge late'>Late</span>";
} elseif ($status == 'absent') {
    echo "<span class='status-badge absent'>Absent</span>";
}

Build docs developers (and LLMs) love