<?php
//include("../../database.inc.php"); //database.inc.php is databse connection file which will be included
include("../../../include/startup.php"); 
if(isset($_REQUEST['action']) && $_REQUEST['action']=='change_status'){
  $page_id = $_REQUEST['page_id'];  
  $new_status = ($_REQUEST['status'] == 0) ? 1 : 0; 
  if($page_id){
    $update_page = "UPDATE pages SET live ='".$new_status."' WHERE id='".$page_id."' ";
    if(mysqli_query($conn,$update_page)){
      echo "Page status changed";
    }
  }else{
    echo "Page status not changed";
  }
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='check_country_exist'){
	$country = $_REQUEST['country'];
	$id = $_REQUEST['id'];
	$where = "";
	if(isset($id) && $id !=""){
		$where = " AND id != '$id' ";
	}
	$returnArray = array();
	$sql = "SELECT * FROM country WHERE country = '$country' $where ";
	$rs = mysqli_query($conn,$sql);
	if(mysqli_num_rows($rs) > 0){
		$row = mysqli_fetch_assoc($rs);
		$returnArray['status'] = "failure";
	}else{
		$returnArray['status'] = "success";
	}
	echo json_encode($returnArray);	
}
die;
?>