<?php
ob_start();
//session_start();
//if(isset($_SESSION['loggedin']))
//{
	include('connection.php');
//	$logid=$_SESSION['loggedin'];
//	$res=mysqli_query($con,"select * from admin where id='$logid'");
//	$row=mysqli_fetch_assoc($res);

	$gid=$_REQUEST['bid'];
	$memm=mysqli_query($con,"select * from slider where id='$gid'");
	$brow=mysqli_fetch_assoc($memm);
	if(isset($_POST['save']))
{
$head=$_POST["head"];
$des=$_POST["des"];
date_default_timezone_set("Asia/Calcutta");
$date=date('Y-m-d H:i:s');
if($_FILES['photo']['tmp_name']=='')
    {
    	$sql="update slider set head='$head',des='$des',updated_at='$date' where id='$gid'";
	
    }
    else
    {
if(is_uploaded_file($_FILES['photo']['tmp_name']))
	{
		$filename=$_FILES['photo']['name'];
    	$filename1=md5($filename).".png";
		move_uploaded_file($_FILES['photo']['tmp_name'],"upload/$filename1");
		$sql="update slider set photo='$filename1',head='$head',des='$des',updated_at='$date' where id='$gid'";
	
	} 
}

$result=mysqli_query($con,$sql);
	if(mysqli_affected_rows($con)==1)
	{
		header("location:slider.php");
	}
	else{
	header("location:slider.php");
	}
}
	
?>

  <!-- Navbar -->
<?php include('header.php');?>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
<?php include('sidebar.php');?>

  <!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
         
          
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
	  <div class="row">
             <div class="col-md-6">
            <!-- general form elements -->
               <div class="card card-info">
              <div class="card-header"style="background-color:rgb(27 125 151);color:white;">
                <h3 class="card-title"><b>Update Banner </b></h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
			   <form method="post" method="post" enctype="multipart/form-data">
                <div class="card-body">
			<div class="form-group">
                    <label for="exampleInputEmail1">Heading</label>
                    <input type="text" name="head" class="form-control" id="exampleInputEmail1"  value="<?php echo $brow['head'];?>" >
                  </div>                 
                	<!--  <div class="form-group">
                    <label for="exampleInputPassword1">Description</label>
                    <input type="text" name="des" class="form-control" id="exampleInputPassword1"  value="<?php echo $brow['des'];?>" >
                  </div>   --> 
                 <div class="form-group">
                    <label for="exampleInputPassword1">Banner</label>
                    <input type="file" name="photo" class="form-control" id="exampleInputPassword1" value="<?php echo $brow['photo'];?>" >
                  </div>    				  
               
                   				  
                </div>
                <!-- /.card-body -->
                <div class="card-footer" style="text-align:right">
                  <button type="submit" name="save" class="btn btn-info">Update</button>
                </div>
              </form>
			  </div>           
          </div>
		 
      </div>
	 
	  </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  
 <?php include('footer.php');?>