Beispiel #1
0
include_once 'header.php';
if (!isset($_POST['submit'])) {
    header('location:student.php?error=nopage');
}
$student = new Student();
$student->set_first_name($_POST['first_name']);
$student->set_last_name($_POST['last_name']);
$student->set_dob($_POST['dob']);
$student->set_blood_group($_POST['blood_group']);
$student->set_email($_POST['email']);
$student->set_contact($_POST['contact']);
$student->set_program_id($_POST['program_id']);
$student_repository = new StudentRepository();
$result_add = 0;
$result_edit = 0;
if (!isset($_POST['id']) || $_POST['id'] == '') {
    $result_add = $student_repository->insert($student);
} else {
    $student->set_id($_POST['id']);
    $result_edit = $student_repository->update($student);
}
if ($result_add > 0) {
    header('location:student.php?success=true');
} elseif ($result_edit > 0) {
    header('location:student.php?update=true');
} elseif ($result_edit == 0) {
    header('location:student.php?update=false');
} else {
    header('location:student.php?error=true');
}
include_once 'footer.php';
Beispiel #2
0
<?php

include_once "config.php";
include_once ROOT_PATH . "students/header.php";
require_once ROOT_PATH . "system/models/students.class.php";
require_once ROOT_PATH . "system/dbutil/dbconnection.class.php";
require_once ROOT_PATH . "system/repository/studentrepository.class.php";
$students = new Students();
$students->set_first_name($_POST['first_name']);
$students->set_last_name($_POST['last_name']);
$students->set_email($_POST['email']);
$students->set_contact_no($_POST['first_name']);
$students->set_course($_POST['course']);
$studentrepository = new StudentRepository();
$success = false;
if (isset($_POST['id']) && $_POST['id'] == '') {
    $result = $studentrepository->insert($students);
} else {
    $result = $studentrepository->update($students);
}
if ($result > 0) {
    header("location:index.php?success=true");
} else {
    header("location:index.php?error=true");
}
exit;