<?php  
include ('../includes/connection.php'); 
$subject_id=$_GET['id']; 
if (isset($_POST['update'])) {  
$subject_id=$_GET['id']; 
$course_code = $_POST['course_code']; 
$subject_name = $_POST['subject_name'];
$user_type = $_POST['user_type'];
$description = mysqli_real_escape_string($conn, $_POST['description']);
 
 
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);

move_uploaded_file($_FILES["image"]["tmp_name"], "../assets/img/academy/" . $_FILES["image"]["name"]);
$adminthumbnails = "assets/img/academy/" . $_FILES["image"]["name"];

      
      mysqli_query($conn,"UPDATE subject_soes SET subject_name='$subject_name',user_type='$user_type', course_image = '$adminthumbnails',course_code='$course_code', description = '$description' where subject_id = '$subject_id'")or die(mysqli_error());

mysqli_query($conn,"UPDATE subject_soes SET subject_name='$subject_name',user_type='$user_type', course_image = '$adminthumbnails',course_code='$course_code', description = '$description' where subject_id = '$subject_id'") 
or die(mysqli_error()); 
?>
<script type="text/javascript">
   alert("Course successfully change");
</script>
<?php  
} 

?> 
 <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h5><strong>Update update_couse</strong></h5>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item"><a href="#">Manage User</a></li>
              <li class="breadcrumb-item active">update_couse</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
    <?php 
    $query= mysqli_query($conn,"SELECT *  FROm  subject_soes  WHERE subject_id='$subject_id'")or die(mysqli_error());
    $row = mysqli_fetch_array($query);   
    ?> 
   <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row"> 
          <!-- /.col -->
          <div class="col-md-12">
            <div class="card"> 
              <!-- /.card-header --> 
              <div class="card-body"> 
                <div class="tab-content">
                   <!-- /.tab-pane -->
                  <div class="active tab-pane" id="timeline">
                   <div class="card card-default">
                    <div class="card-header">
                      <h3 class="card-title">Update Course:  <strong><?php echo $row['subject_name']?></strong></h3> 
                      <div class="card-tools">
                        <button type="button" class="btn btn-tool" data-card-widget="collapse">
                          <i class="fas fa-minus"></i>
                        </button> 
                      </div>
                    </div>
                    <form action="" method="post" enctype="multipart/form-data"> 
                    <!-- /.card-header -->
                    <div class="card-body"> 
                        <!-- /.col -->
                       <div class="row">
                       <div class="col-sm-6">    
                         <div class="modal-body">
                          <span id="form_message"></span>
                             <div class="form-group">
                               <label>Course Code <span style="color: red;">*</span></label>
                                <input type="text" name="course_code" id="course_code" class="form-control select2" value="<?php echo $row['course_code']?>">
                              </div>
                              <div class="form-group">
                               <label>Course Name <span style="color: red;">*</span></label>
                                <input type="text" name="subject_name" id="subject_name" class="form-control select2" value="<?php echo $row['subject_name']?>">
                              </div>
                              <div class="form-group">
                               <label>Course Type <span style="color: red;">*</span></label>
                                <select name="user_type" id="user_type" class="form-control select2" required>
                                    <option ><?php echo $row['user_type']?></option>
                                    <option value="Professional">Professional Cybershield</option>
                                    <option value="Digital">Digital User</option> 
                                </select>
                              </div> 
                              <div class="form-group">
                                  <label>Course Description <span style="color: red;">*</span></label>
                                  <textarea type="text" name="description" id="description" class="form-control select2" value="<?php echo $row['description']?>" required><?php echo $row['description']?></textarea> 
                              </div>
                               <div class="form-group">
                                  <label>Upload Image <span style="color: red;">*</span></label>
                                      <input type="file" class="form-control" name="image"  id="fileInput" placeholder="Change profile picture">
                                </div>
                                <!--<div class="form-group">-->
                                <!--  <label>Upload Certificate <span style="color: red;">*</span></label>-->
                                <!--      <input type="file" class="form-control" name="certificate"  id="fileInput1"  placeholder="Change certificate">-->
                                <!--</div>-->
                            </div>
                          </div>
                          <div class="col-sm-6"> 
                             <img src="../<?php echo $row['course_image']; ?>" class="img-thumbnail" width="100%" height="100%" />
                          </div>
                       </div> 


                         <div class="modal-footer">  
                          <a class="btn btn-secondary" href="admin.php?page=course"><< Back </a>
                          <button type="submit" class="btn btn-primary" name="update">UPDATE </button>
                      </div>
                      <!-- /.row -->
                    </div> 
                  </form>
                  </div>
                   
                    </div>
                    
                     
                     
                  </div>
                  
                  <!-- /.tab-pane -->
                </div>
                <!-- /.tab-content -->
              </div><!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div> 
   <a id="back-to-top" href="#" class="btn btn-primary back-to-top" role="button" aria-label="Scroll to top">
      <i class="fas fa-chevron-up"></i>
    </a>
  <div id="preloader"></div>
  
<script src="../stp_con/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../stp_con/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables  & Plugins -->
<script src="../stp_con/datatables/jquery.dataTables.min.js"></script>
<script src="../stp_con/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../stp_con/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../stp_con/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="../stp_con/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="../stp_con/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="../stp_con/jszip/jszip.min.js"></script> 
<script src="../stp_con/pdfmake/pdfmake.min.js"></script>  
  

 
 
