<?php

 error_reporting(0);
include("../include/config.php"); 


##########################################################################################
      
if(array_key_exists("add_slider_img",$_REQUEST)){
//    echo "sli"; die;
    
            if(isset($_FILES['image_a']['name']))

                {

                    $fileName1 = time().$_FILES["image_a"]["name"];   

                    $fileTmpLoc1 = $_FILES["image_a"]["tmp_name"];

                    $fileType1 = $_FILES["image_a"]["type"];

                    $fileSize1 = $_FILES["image_a"]["size"];

                    $fileErrorMsg1 = $_FILES["image_a"]["error"];

                    $kaboom1 = explode(".", $fileName1);

                    $fileExt1 = end($kaboom1);



                    $moveResult1 = move_uploaded_file($fileTmpLoc1, "slider-images/$fileName1"); 

                }

    


            $query = "INSERT INTO `slider`(`slider_img`, `status`) VALUES ('$fileName1', 'active');";

           if (mysqli_query($conn, $query)) {
				header("location:slider.php");
			} 
			else {
                echo "qu faild to update data";
			}
			mysqli_close($conn);

    }      
###################################################################################


##########################################################################################

// status active  data
if(array_key_exists("status_active_slider",$_REQUEST)){
   
        $net_id = $_GET['id'];
        
        	 $query="UPDATE `slider` SET `status` = 'active' WHERE `slider`.`id` = '$net_id'";

			if (mysqli_query($conn, $query)) {
				header("location:slider.php");
			} 
            
			else {
				include('include/error-modal.php');
			}
			mysqli_close($conn);
    
}

##########################################################################################
// status deactive data
if(array_key_exists("status_deactive_slider",$_REQUEST)){
    
  $net_id = $_GET['id'];
        
        	 $query="UPDATE `slider` SET `status` = 'deactive' WHERE `slider`.`id` = '$net_id'";
		
            
			if (mysqli_query($conn, $query)) {
				header("location:slider.php");
			} 
            
			else {
				include('include/error-modal.php');
			}
			mysqli_close($conn);
    
}


##################################################################################################

//For detete data
if(array_key_exists("Delete_slider",$_REQUEST)){
    
    $t_id = $_GET['id'];
    
//  echo $t_id; die;
    
        
    $query="DELETE FROM `slider` WHERE `slider`.`id` = '$t_id'";
			
            
            
			if (mysqli_query($conn, $query)) {
				header("location:slider.php");
			} 
            
			else {
				include('include/error-modal.php');
			}
			mysqli_close($conn);
}
?>