<?php
	session_name('library');
	session_start();
	
	include("functions.php");

	head('Category Management - Adding');
?>

<body>
<div id="main">

	<?php
		include("header.php");
		include("menu.php");
	?>

		
	

<div id="entire_panel">
		<h1>Pridaj kategóriu</h1>
		<?php
			 

if ($_SESSION['admin'] == 1) {
	if(!isset($_POST['submit'])){ ?>
	<table border=0 cellspacing=3 cellpadding=3>
	<form name=register method=post action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
		<tr>
			<td>Názov:</td>
			<td><input type=text name=name maxlength=32></td>
		</tr>
		
		<tr>
			<td colspan=2 align=right><input name="submit" type="submit" id="submit" value="Pridaj"></td>
		</tr>
	</form>
	</table>
	<?php

	}else{
	
		$link = connect_db();
	
		$name = $_POST['name'];
		protect($name);
		
		if (isset($name)){		
				
			$sql = "INSERT INTO book_categories SET name='" . $name . "'";
			$result = mysql_query($sql) or die(mysql_error());
			
			echo '<p id="bold">The category was added successfully.</p>';
			
		}
	}
} else {
	echo '<p id="red">K tejto stránke nemáte dostatočné oprávnenia</p>';
}    
		?>				
</div>

	<?php include("footer.php"); ?>

</div>
</body>
</html>

