Mini Shell

Direktori : /home/rizant5/www/admin/
Upload File :
Current File : /home/rizant5/www/admin/course-edit.php

<?php 
require_once("../config.php");
require_once("function-file.php");
require_once("function-menu.php");
cookiecheck();
$course_id=$_GET['courseid'];
$datas=$conn->prepare("select * from courses where course_id='$course_id'");
$datas->execute();$result=$datas->fetch();
if(isset($_POST['save'])){
	if(!empty($_FILES['course_image']['name'])){
		//Upload Image
		$name=$_FILES['course_image']['name'];
		$course_images=str_replace(" ","_",$name);
		$tmp_name=$_FILES['course_image']['tmp_name'];
		$target_path="img/courses/";
		$target_path=$target_path.basename($course_images);
		move_uploaded_file($_FILES['course_image']['tmp_name'],$target_path);
		//--
	}
	else{$course_images=$result['course_image'];}
	$course_name=$_POST['course_name'];
  $course_fees=$_POST['course_fees'];
  
  $discount = $_POST["discount"];
  $course_status = $_POST["course_status"];

	$course_overview=$_POST['course_overview'];
	$conn->exec("UPDATE courses SET course_name='$course_name',course_fees='$course_fees',course_overview='$course_overview',course_image='$course_images',discount='$discount',av_status='$course_status' where course_id='$course_id'");
	header("location:courses.php");
}
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Edit Course</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <?php  cssfile();?>
  </head>
  <body class="hold-transition skin-blue layout-top-nav">
    <!-- Site wrapper -->
    <div class="wrapper">
<?php headermenu();?>
      <!-- =============================================== -->
      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <!-- Main content -->
        <section class="content">
          <!-- Default box -->
          <div class="box">
            <div class="box-header with-border">
              <h3 class="box-title">Edit Course</h3>
              <div class="box-tools pull-right">
                <a href="courses.php" class="btn btn-info btn-sm" ><i class="fa fa-angle-double-left"></i> Back</a>
              </div>
            </div>
            <div class="box-body">
            <form action="#" method="post" role="form" class="form-horizontal" enctype="multipart/form-data">

              <div class="form-group col-md-8">
                  
                  <div class="col-md-12" style="padding:0px;">
                    <div class="col-md-6 col-sm-4"><label>Course Name</label><input name="course_name" class="form-control" placeholder="Enter Course Name" value="<?php echo $result['course_name']; ?>"></div>
                    <div class="col-md-6 col-sm-4"><label>Course Fees</label><input name="course_fees" class="form-control ratenum" placeholder="Enter Course Fees" value="<?php echo $result['course_fees']; ?>"></div>
                    <div class="col-md-6 col-sm-4"><label>Discount</label><input name="discount" class="form-control ratenum" placeholder="Enter Discount %" value="<?php echo $result['discount']; ?>"></div>
                    <?php
                      if($result['av_status'] == 1){
                        echo '<div class="col-md-5 col-sm-4 cs-checkbox"><label>Course Status </label><input type="checkbox" name="course_status" checked value="1"></div>';
                      }
                      else{
                        echo '<div class="col-md-5 col-sm-4 cs-checkbox"><label>Course Status </label><input type="checkbox" name="course_status" value="1"></div>';
                      }
                    
                    ?>
                    
                  </div>

                  <div class="col-sm-12">
                    <label>Course Overview</label>
                    <textarea name="course_overview" class="form-control" placeholder="Type Course Overview" rows="4"><?php echo $result['course_overview']; ?></textarea>
                  </div>

              </div>


                <div class="form-group col-md-4" style="float:right;margin-left:0px;padding-left:0px;">
                    <div class="col-md-12">
                      <label>Course Image:</label><br>
                      <input type="file" id="file" name="course_image" type="file" class="form-control"  accept="image/*" onchange="loadFile(event)">
                    </div>
                    
                    <div class="col-md-12 col-sm-4" style="margin-top:5px;"><img src="img/courses/<?php echo $result['course_image'];?>" id="output" style="max-height:250px;width:100%" class="img-responsive img-thumbnail"/></div>
                </div>


                <div class="form-group col-md-12" style="text-align: right;float:right;">
                    <div class="col-sm-12">
                      <button type="reset"  class="btn btn-default" rows="4">Reset</button>&nbsp;&nbsp;
                      <button  type="submit" name="save" class="btn btn-success" >Save</button>
                    </div>
                </div>


              </form>
            </div><!-- /.box-body -->
          </div><!-- /.box -->
        </section><!-- /.content -->
      </div></div><!-- /.content-wrapper -->
      <?php footer();?>
    </div><!-- ./wrapper -->
   <?php jsfile();ratenum();?>
   <script>
  var loadFile = function(event) {
    var output = document.getElementById('output');
    output.src = URL.createObjectURL(event.target.files[0]);
  };
</script>
  </body>
</html>

Zerion Mini Shell 1.0