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


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

if(isset($_POST['update']))
{   
  $careers['careers_title'] = str_replace("'","\'", $_POST['careers_title']);
  $careers['careers_text'] = str_replace("'","\'", $_POST['careers_text']);
  $server_url = '//'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    $upload_dir = '../uploads/career/';
        
        if(!empty($_FILES['careers_img']['name']))
        {            
            $tempname = $_FILES['careers_img']['tmp_name'];
            $upload_name = $upload_dir.$_FILES['careers_img']['name'];
            move_uploaded_file($tempname,$upload_name);
            $careers['careers_img'] = $server_url."/".$upload_name;
        }
        else
        {
            $careers['careers_img'] =$_POST['careers_img1'];
        }
		    
    $ex = $obj->update_career_content($careers);
    echo '<script>window.location="career.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>Career Top Content
                <a href="career.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">
                  <div class="form-group">
                  <label>Career Title</label>
				  <input type="text" class="form-control" name="careers_title" value="<?php echo $row['careers_title'];?>">
                 </div>
				  
				  <div class="form-group">
                  <label>Career Text</label>
                  <textarea id="w3review" name="careers_text" rows="6" cols="50" class="tinymce"><?php echo $row['careers_text'];?></textarea>
                  </div>
				  
                 <div class="form-group">
                     <label>Section1 Image</label><br>
                     <input type="file" class="" name="careers_img" value="<?php echo $row['careers_img'];?>">
                       <input type="hidden" name="careers_img1" value="<?php echo $row['careers_img'];?>">
                       <img src="<?php echo $row['careers_img'];?>"  style="width: 300px;">
                 </div>
                       
					   <button type="submit" class="btn btn-primary" name="update">Update</button>
                  
                </form> 
				
				 
            </div>
        </div>
    </div>
</main>

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

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

