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

if(isset($_POST['update']))
{   
  $what_make['what_make_title'] = str_replace("'","\'", $_POST['what_make_title']);
  $what_make['what_make_text'] = str_replace("'","\'", $_POST['what_make_text']);
    $server_url = '//'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    $upload_dir = '../uploads/home/';
        
        if(!empty($_FILES['what_make_bg_img']['name']))
        {            
            $tempname = $_FILES['what_make_bg_img']['tmp_name'];
            $upload_name = $upload_dir.$_FILES['what_make_bg_img']['name'];
            move_uploaded_file($tempname,$upload_name);
            $what_make['what_make_bg_img'] = $server_url."/".$upload_name;
        }
        else
        {
            $what_make['what_make_bg_img'] =$_POST['what_make_bg_img1'];
        }

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

<?php
	$ex = $obj->view_what_make_section();
    $row = mysqli_fetch_array($ex);
?>

<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>What Make
                <a href="what_make.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>What Make Title</label>
						<input type="text" name="what_make_title" class="form-control" value="<?php echo $row['what_make_title'];?>">
					 </div>
					
                   <div class="form-group">
                  <label>What Make Text</label>
                  <textarea id="w3review" name="what_make_text" rows="6" cols="50" class="tinymce"><?php echo $row['what_make_text'];?></textarea>
                  </div>
				  
					 <div class="form-group">
						 <label>What Make Background Img</label><br>
						 <input type="file" class="" name="what_make_bg_img" value="<?php echo $row['what_make_bg_img'];?>">
						   <input type="hidden" name="what_make_bg_img1" value="<?php echo $row['what_make_bg_img'];?>">
						   <img src="<?php echo $row['what_make_bg_img'];?>"  style="width: 100px;">
                     </div>
                        

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

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

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

