<?php

	require_once('../libs/Ultraviolet.php');

	require_once('../libs/Database.php');

	require_once('../libs/AdminFunctions.php');
	
	require_once('../libs/SimpleImage.php');
	
	require_once('../libs/FileUpload.php');

	

	$database =& DatabaseConnect::getInstance();

	$functions =& AdminFunctions::getInstance();

	$database->query("SET CHARACTER SET utf8");



	for($i = 0; $i < count($_POST); $i++):

		${key($_POST)} = $_POST[key($_POST)];

		next($_POST);	

	endfor;
	
	$clientname = str_replace("'", "`", $clientname);
	
	$database->setBareQuery("SELECT id FROM client WHERE name = '$clientname'");

	$id = $database->loadResultArray(0);
		
	if(count($id) == 0):

	if($clientname != ''):

		if($database->query("INSERT INTO client(name) VALUES('$clientname')")):

			echo "success";

		else:

			echo mysql_errno()." ".mysql_error();

		endif;
		
	else:
	
		echo 'Morate uneti ime klijenta!';
		
	endif;
	
	else:
		
		echo 'Klijent sa tim imenom već postoji';
		
	endif;
	


?>