In this section, we will register a student for a course. We will allow the users to register a student to a course by accepting the student ID and course ID. We will add the new StudentsCourses
controller to our controllers
directory and it will extend the Base_Controller
class. Upon instantiation, we will load the StudentCourses
model (similar to other controllers in the application) in the controllers/studentsCourses.php
file:
<?php class StudentsCourses extends Base_Controller{ public function __construct(){ parent::__construct(); $this->loadModel("studentsCourses"); } public function register(){ if(isset($_POST['submit'])){ unset($_POST['submit']); $student_id = $_POST['student_id']; $course_id = $_POST['course_id']; $this->view->id = $this->model->registerStudentCourse($student_id, $course_id); } $this->view->render('studentsCourses/register'); } }