<?php
session_start();

include "../functions.php";

include "../conn.php";

checkAdmin(session_id());

$submit = $_POST["submit"];

if (isset($submit))
{
	$catname = $_POST["catname"];
	$catdescrip = $_POST["catdescrip"];
	
	
	$query = "select * from jobcat where catname='$catname'";
	$result = mysql_query($query);
	if (mysql_num_rows($result) > 0)
	{
		$err .= "<li>there is already a category called $catname</li>";
	}
	if (!isset($err))
	{
		$query = "insert into jobcat (catname, catdescrip) values ('$catname', '$catdescrip')";
		mysql_query($query) or die(mysql_error());
		header ("location: cat.php");
	}
}
?>
<?php
$title = "Add Job Category";
include "header.php";
?>
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post">
<center>
<table border=0 width=80% cellpadding=5>
<?php
if ($err)
{
	$err = "<font color=red>the following error occured when adding new group<p>" . $err . "</font>";
	echo "<tr><td colspan=2 bgcolor=yellow><ul>";
	echo $err;
	echo "</ul></td></tr>";
}
?>
<tr>
<td align="right">Category Name:</td>
<td align="left"><input type="text" name="catname" size=50></td>
</tr>

<tr>
<td align="right" valign="top">Category Description:</td>
<td align="left"><textarea name="catdescrip" rows=6 cols=40 wrap=virtual></textarea></td>
</tr>

<tr>
<td align="center" colspan=2><input type="hidden" name="submit" value=1><input type="submit" value="Add">&nbsp;<input type="reset" value="Clear"></td>
</tr>
</table>
</center>
</form>

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