Advertisement
Guest User

Untitled

a guest
Mar 18th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. if (isset($_SESSION['username'])){
  5.  
  6.  
  7. require '../admin/config.php';
  8. require '../admin/functions.php';
  9. require '../views/header.view.php';
  10. require '../views/navbar.view.php';
  11.  
  12. $connect = connect($database);
  13. if(!$connect){
  14. header ('Location: ' . SITE_URL . '/controller/error.php');
  15. }
  16.  
  17. if ($_SERVER['REQUEST_METHOD'] == 'POST'){
  18.  
  19. $student_id = cleardata($_POST['student_id']);
  20. $student_name = cleardata($_POST['student_name']);
  21. $student_image_save = $_POST['student_image_save'];
  22. $student_image = $_FILES['student_image'];
  23.  
  24. if (empty($student_image['name'])) {
  25. $student_image = $student_image_save;
  26. } else{
  27. $student_image_upload = '../' . $items_config['images_folder'] . $_FILES['student_image']['name'];
  28. move_uploaded_file($_FILES['student_image']['tmp_name'], $student_image_upload);
  29. $student_image = $_FILES['student_image']['name'];
  30. }
  31.  
  32.  
  33. $statment = $connect->prepare(
  34. 'UPDATE students SET student_name = :student_name, student_image = :student_image WHERE student_id = :student_id'
  35. );
  36.  
  37. $statment->execute(array(
  38.  
  39. ':student_name' => $student_name,
  40. ':student_image' => $student_image,
  41. ':student_id' => $student_id
  42.  
  43. ));
  44.  
  45. header('Location:' . SITE_URL . '/controller/home.php');
  46.  
  47. } else{
  48.  
  49. $id_student = id_student($_GET['id']);
  50.  
  51. if(empty($id_student)){
  52. header('Location: home.php');
  53. }
  54.  
  55. $student = get_student_per_id($connect, $id_student);
  56.  
  57. if (!$student){
  58. header('Location: ' . SITE_URL . '/controller/home.php');
  59. }
  60.  
  61. $student = $student['0'];
  62.  
  63. }
  64.  
  65. $course_lists = get_courses($connect);
  66. $courses_selected = selected_courses($connect);
  67. $courses_not_selected = not_selected_courses($connect);
  68.  
  69. require '../views/edit.student.view.php';
  70. require '../views/footer.view.php';
  71.  
  72. }else {
  73. header('Location: ' . SITE_URL . '/controller/login.php');
  74. }
  75.  
  76.  
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement