Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if (isset($_SESSION['username'])){
- require '../admin/config.php';
- require '../admin/functions.php';
- require '../views/header.view.php';
- require '../views/navbar.view.php';
- $connect = connect($database);
- if(!$connect){
- header ('Location: ' . SITE_URL . '/controller/error.php');
- }
- if ($_SERVER['REQUEST_METHOD'] == 'POST'){
- $student_id = cleardata($_POST['student_id']);
- $student_name = cleardata($_POST['student_name']);
- $student_image_save = $_POST['student_image_save'];
- $student_image = $_FILES['student_image'];
- if (empty($student_image['name'])) {
- $student_image = $student_image_save;
- } else{
- $student_image_upload = '../' . $items_config['images_folder'] . $_FILES['student_image']['name'];
- move_uploaded_file($_FILES['student_image']['tmp_name'], $student_image_upload);
- $student_image = $_FILES['student_image']['name'];
- }
- $statment = $connect->prepare(
- 'UPDATE students SET student_name = :student_name, student_image = :student_image WHERE student_id = :student_id'
- );
- $statment->execute(array(
- ':student_name' => $student_name,
- ':student_image' => $student_image,
- ':student_id' => $student_id
- ));
- header('Location:' . SITE_URL . '/controller/home.php');
- } else{
- $id_student = id_student($_GET['id']);
- if(empty($id_student)){
- header('Location: home.php');
- }
- $student = get_student_per_id($connect, $id_student);
- if (!$student){
- header('Location: ' . SITE_URL . '/controller/home.php');
- }
- $student = $student['0'];
- }
- $course_lists = get_courses($connect);
- $courses_selected = selected_courses($connect);
- $courses_not_selected = not_selected_courses($connect);
- require '../views/edit.student.view.php';
- require '../views/footer.view.php';
- }else {
- header('Location: ' . SITE_URL . '/controller/login.php');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement