<?php

require_once '../library/config.php';
require_once '../library/functions.php';

checkUser();

$action = isset($_GET['action']) ? $_GET['action'] : '';

switch ($action) {
	
	case 'add' :
		addFile();
		break;
		
	case 'modify' :
		modifyFile();
		break;
		
	case 'delete' :
		deleteClient();
		break;
  case 'deleteimg' :
		deleteImage();
		break;
   case 'deleteimg1' :
		deleteImage1();
		break;		
	case 'deleteimg2' :
		deleteImage2();
		break;			
	default :
	    // if action is not defined or unknown
		// move to main user page
		header('Location: index.php');
}


function addFile()
{	
	@$title   = $_REQUEST["txttitle"];	
	@$Detail  = filter($_REQUEST['txtdetail']);
	 
    $sql   = "INSERT INTO tbl_testimonials(Title, detail)
		      VALUES ('$title', '$Detail')";
		
		//die();
		dbQuery($sql);
		header('Location: index.php');	
	}

/*
	Modify a user
*/
function modifyFile()
{	
    $fileId   	 	 = $_REQUEST['hidFileId'];
	@$title   = $_REQUEST["txttitle"];	
	@$Detail  = filter($_REQUEST['txtdetail']);
	
   
		
	 $sql5 ="update tbl_testimonials set Title = '$title', detail = '$Detail' where Id = $fileId";
		//die();
		 dbQuery($sql5);
		
		header('Location:index.php');	
}
?>