<?php


//&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=I

if($_GET['act']== 'deregister_rc')
{

    $user_id = $_REQUEST['u'];//programme id
    $cid = $_REQUEST['cid'];//programme id
    $pid = $_REQUEST['pid'];//programme id
   // $sid = $_REQUEST['sid'];//school id
    $ses = $_REQUEST['ses'];//session passed
    $sem = $_REQUEST['sem'];//semster passed
    $level = $_REQUEST['level'];//semster passed




    //get student department
    $dept = get_student_department_id($user_id);

    $programme_type = get_student_programme_type_id($user_id);


    $student_id = $user_id; //just pass user id to student id for easy calling


    //get student matric no
    $mat_no = get_student_mat_no($user_id);




//insert unique token incase of delete or update
   //$token = delete_course_token();


  // $id_array = $_SESSION['course']; // return array
  // //print_r($id_array);
  // $id_count = count($_SESSION['course']); // count array

  // for($i=0; $i < $id_count; $i++) {
  //      $id = $id_array[$i];

       // $course_unit = get_student_course_unit($id); //collect unit to add
       //   $course_semester = get_student_course_semester($id);//collect course semester for showing base on semester


       //get course level from designed programme courses table by passing users programme_id, and courses he choose to register
       $course_level = get_student_course_level_from_pc($pid, $id); // get course level


       // //get seen_as_elective from designed programme courses table by passing users programme_id, and courses he choose to register
       // $seen_as_elective = get_student_seen_as_elective_from_pc($pid, $id);


       // $course_dept_id = get_student_course_dept_id($id); //get course department id

       // $course_category = get_student_course_category($id);


       //exit();
         $token = get_student_course_token($cid, $level, $user_id, $ses);


        //exit();

    //INSERT INTO perm TB
    $q5 = "DELETE FROM students_courses_nce WHERE student_id = $user_id AND  course_id = $cid AND session_id = $ses AND  delete_token = '$token'";

    $r5 = mysqli_query($dbc,$q5);

    //if insertin is successful
    //clear the session 'course'
    //unset($_SESSION['course']);
    //unset($_SESSION['cs']);



    if(!$r5) { die("<span class='btn btn-danger'>SERVER ERROR: Please retry again</span>"); }



  //}//end of for


    if($r5)
    {




      //exit();//


      header("Location: gateway.php?act=view_course_reg&pid=".$pid."&u=".$user_id."&ses=".$ses."&sem=".$sem."&level=".$level."&is=Course resgistration is done for this student &qlk=".md5(3));
    }





  }//end of if isset

  ?>
