<?php
session_start();

include "../conn.php";
include "../functions.php";

checkAdmin(session_id());


$submit = $_POST["submit"];

if (isset($submit))
{
	$catname = $_POST["catname"];
	$catdescrip = $_POST["catdescrip"];
	$jobcatid = $_POST["jobcatid"];
	
	$query = "update jobcat set catname='$catname', catdescrip='$catdescrip' where jobcatid=$jobcatid";
	//echo $query;
	mysql_query($query) or die(mysql_error());
	header ("location: cat.php");
}
?>
<?php
include "header.php";
$jobcatid = $_POST["jobcatid"];
?>
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post">
<center>
<table border=0 width=80% cellpadding=5>
<?php

$query = "select catname, catdescrip from jobcat where jobcatid='$jobcatid'";
$result = mysql_query($query) or die (mysql_error());
if (mysql_num_rows($result) < 1)
{
	echo "there is no such category";
	exit;
}

$row = mysql_fetch_array($result);

$catname = $row[0];
$catdescrip = $row[1];

if ($err)
{
	$err = "<font color=red>the following error occured when adding new category<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 value="<?php echo $catname; ?>"></td>
</tr>

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

<tr>
<td align="center" colspan=2><input type="hidden" name="submit" value=1><input type="hidden" name="jobcatid" value="<?php echo $jobcatid; ?>"><input type="submit" value="Modify">&nbsp;<input type="reset" value="Clear"></td>
</tr>
</table>
</center>
</form>


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