<?php session_start();  //Developed by ITechScripts
require 'include/configurations.php'; // ITECHBIDS Configuration File
$frm=$_POST["cate"];
$category=$_POST["cat"];
$serial=$_POST["ser"];
$mode=$_REQUEST[mode];
$categoryid=$_REQUEST['id'];
require 'include/header.php';
if($mode=='edit')
{
$cat_sql="select * from site_categories where category_id=$categoryid";
$cat_res=mysql_query($cat_sql);
$cat_row=mysql_fetch_array($cat_res);
}
if($frm==1)
{
      if($mode=="edit")
       {
         $sql1="update site_categories set category_name='$category',serial='$serial' where category_id=$categoryid";
         $res1=mysql_query($sql1);
	   }
      else
      {
          $sql="insert into site_categories(category_name,serial) values('$category','$serial')";
         $res=mysql_query($sql);
		 	 
      }
	  
    echo '<meta http-equiv="refresh" content="0;url=category.php">';
}
 
?>
<html>
<body>
<form action="addcategory.php" method="post">

  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <table align="center" class="ft" width=600>
<td colspan="2" class="ct" height="25" align="left">
<? 
if($mode=='edit')
{
echo ("Edit Category");
}
else
{
echo ("Add Category");
}
?>
</td>
<tr height="25" >
<td align="center"  > <span height="25">
Category Name</span>&nbsp;&nbsp;</td><td>
<input type="text" class="bluetext"name="cat" value="<?=$cat_row[category_name];?>" style="width:300;" >
</td></tr>

<tr height="25" >
<td align="center"  > <span height="25">
Serial No.</span>&nbsp;&nbsp;</td><td>
<input type="text" class="bluetext"name="ser" value="<?=$cat_row[serial];?>" style="width:100;" >
<input type="hidden" name="cate" value=1>
<input type="hidden" name="mode" value=<?= $mode;?> >
<input type="hidden" name="id" value=<?= $categoryid;?> >
</td></tr>
<tr height="25" >
<td align="center" colspan="2">
<input  type="submit" class="button" name="add" value="Submit" >
</td></tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form></body></html>
<?
	require 'include/footer.php';
?>