<?php
require_once("header.php");
require_once("menu.php");

    $ex = $obj->view_video_section();
    $row = mysqli_fetch_array($ex);
	

if(isset($_POST['update']))
{   
  $update_video['home_video_id'] = $_POST['home_video_id'];
  $update_video['home_video_text'] = str_replace("'","\'", $_POST['home_video_text']);
  $server_url = '//'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    $upload_dir = '../uploads/video/';
        
        if(!empty($_FILES['home_video']['name']))
        {            
            $tempname = $_FILES['home_video']['tmp_name'];
            $upload_name = $upload_dir.$_FILES['home_video']['name'];
            move_uploaded_file($tempname,$upload_name);
            $update_video['home_video'] = $server_url."/".$upload_name;
        }
        else
        {
            $update_video['home_video'] =$_POST['home_video1'];
        }

       
    $ex = $obj->update_video_section($update_video);
    echo '<script>window.location="video.php"</script>';
}
?>

<div id="layoutSidenav_content">
<main class="mt-4">
    <div class="container-fluid">
        
        <div class="card mb-4">
            <div class="card-header">
                <i class="fas fa-check-square mr-1"></i>Video Section
                <a href="video.php" class="btn btn-primary btn-sm float-right">Back</a>
            </div>
            <div class="card-body">
                <form method="post" name="frm" id="frm" enctype="multipart/form-data">
                   <input type="hidden" name="home_video_id" value="<?php echo $row['home_video_id'];?>">
                    
                   <div class="form-group">
                  <label>Description</label>
                  <textarea id="w3review" name="home_video_text" rows="6" cols="50" class="tinymce"><?php echo $row['home_video_text'];?></textarea>
                  </div>
				  
					 <div class="form-group">
						 <label>Why Us Image</label><br>
						 <input type="file" class="" name="home_video" value="<?php echo $row['home_video'];?>">
						   <input type="hidden" name="home_video1" value="<?php echo $row['home_video'];?>">
						    <video  class="vidak"  controls="true" muted defaultmuted playsinline style="width: 50%;">
									<source src="<?php echo $row['home_video'];?>" type="video/mp4">
					   </video>
						 
                     </div>
                        

                        <button type="submit" class="btn btn-primary" name="update">Update</button>
                    
                </form> 
            </div>
        </div>
    </div>
</main>

<script>
    var url = "video.php";
</script>

<?php require_once("footer.php");?>

