Overview
TheStudentController manages student records including creation, listing, deletion, and search functionality. All methods require admin authentication.
File Location: app/controllers/StudentController.php
Dependencies:
StudentmodelAuthhelper
Methods
index()
Displays list of all students. Authorization: Admin only Behavior:- Retrieves all student records from database
- Renders student listing view
app/views/students/index.php
create()
Displays student creation form and handles student registration. Authorization: Admin onlyStudent’s full name (POST request)
Student’s email address (POST request)
Student’s password (POST request)
- GET request: Displays creation form
- POST request: Creates new student and redirects
- GET: Renders creation form
- POST: Redirects to
/students
delete()
Deletes a student record. Authorization: Admin onlyStudent ID to delete (from GET query parameter)
- Validates admin authorization
- Deletes student from database
- Redirects to student listing
/students
search()
Searches for students by keyword. Authorization: Admin onlySearch keyword (searches name or email)
- If keyword provided: Returns filtered results
- If no keyword: Returns all students
- Uses the same view as
index()
app/views/students/index.php