<?php
include '../db/db.php';
session_start();
$log= htmlspecialchars(trim($_SESSION['user']), ENT_QUOTES, 'UTF-8');
if (empty($log)) {
	 
  $redirectUrl = "../index.php";
  echo "<script type=\"text/javascript\">";
  echo "window.location.href = '$redirectUrl'";
  echo "</script>";
	 
}else{

  $sqlu="SELECT * FROM details_of_users WHERE user='$log' and val='1'";
  $resultu=mysqli_query($conn, $sqlu);
  $countu=mysqli_num_rows($resultu);
  
	if($countu==1){
		
		if (array_key_exists('load_banner', $_POST)) {
			/*echo $_POST['uname'];*/
			$id = htmlspecialchars(trim($_POST['id']), ENT_QUOTES, 'UTF-8');

			$sql = mysqli_query($conn, "SELECT
main_banner.id,
main_banner.img_name,
main_banner.sub_title,
main_banner.main_title,
main_banner.description,
main_banner.sub_cat,
sub_cat.cat_id
FROM
main_banner
Inner Join sub_cat ON main_banner.sub_cat = sub_cat.id WHERE main_banner.id = $id");	
			$row = mysqli_fetch_assoc($sql);
			
			echo json_encode($row);
			//echo "In";
		}

	} else{
	  $redirectUrl = "../index.php";
	  echo "<script type=\"text/javascript\">";
	  echo "window.location.href = '$redirectUrl'";
	  echo "</script>";
	
	}
}

?>