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

$ex = $obj->get_home_top_banner();
$row1 = mysqli_fetch_array($ex);


if(isset($_POST['update']))
{   
  $home_top_banner['id'] = $row1['id'];
  $home_top_banner['banner_main_text'] = $_POST['banner_main_text'];
  $home_top_banner['banner_animated_text'] = $_POST['banner_animated_text'];
  $home_top_banner['banner_text'] = $_POST['banner_text'];
  $home_top_banner['banner_link'] = $_POST['banner_link'];
   // $server_url = '//'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    $upload_dir = '../uploads/home/';
        
        if(!empty($_FILES['banner_img']['name']))
        {            
            $tempname = $_FILES['banner_img']['tmp_name'];
            $upload_name = $upload_dir.$_FILES['banner_img']['name'];
            move_uploaded_file($tempname,$upload_name);
            $home_top_banner['banner_img'] = $upload_name;
        }
        else
        {
            $home_top_banner['banner_img'] = $_POST['banner_img1'];
        }

       
    $ex = $obj->update_home_top_banner($home_top_banner);
    echo '<script>window.location="home.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>Add Home Information
                <a href="home.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="id" value="<?php echo $row1['id'];?>">
                    <div class="form-group">
                     <label>Home Top Banner Image</label><br>
                     <input type="file" class="" name="banner_img" value="<?php echo $row['banner_img'];?>">
                       <input type="hidden" name="banner_img1" value="<?php echo $row1['banner_img'];?>">
                       <img src="<?php echo $row1['banner_img'];?>"  style="width: 300px;">
                     </div>
					 
					  <div class="form-group">
                  <label>Top Banner Main Text</label>
                 <input type="text" class="form-control" name="banner_main_text" value="<?php echo $row1['banner_main_text'];?>">
				 </div>
                   <div class="form-group">
                  <label>Top Banner Animated Text</label>
                 <input type="text" class="form-control" name="banner_animated_text" value="<?php echo $row1['banner_animated_text'];?>">
				 </div>
				  <div class="form-group">
                  <label>Top Banner Text</label>
                  <textarea id="w3review" name="banner_text" rows="3" cols="20" class="tinymce"><?php echo $row1['banner_text'];?></textarea>
                  </div>
				  <div class="form-group">
                  <label>Banner Button Link</label>
                 <input type="text" name="banner_link" value="<?php echo $row1['banner_link'];?>" class="form-control">
				 </div>
                 <button type="submit" class="btn btn-primary" name="update">Update</button>
                   
                </form> 
            </div>
        </div>
    </div>
</main>

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

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

