<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Add a Record</TITLE>
</HEAD>
<BODY>
<?
/***************************************************************************
 *			do_addcat.php	                                   *
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~	                   *
 *   File Info:		  Add Category                                     *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include("./config.php");
include("./header.inc");
?>
<center><img src=images/computer.gif border=0><font face=verdana size=3 color=navy>  Adding a Record to CATEGORY</font></center><br>
<?
$table = "category";
  if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
        $category = addslashes($_POST["category"]);
        $catid = addslashes($_POST["catid"]);
        $cpic = addslashes($_POST["cpic"]);
	$shiprate = addslashes($_POST["shiprate"]);

}

if ($category != NULL)
{

}else
{
	echo("<center>Cannot continue adding category records - Category field must contain data!</center>");
	echo("<center>Go back and add details before continuing to add a new category record!</center>");
echo "<center><a href=show_addrecord3.html><img src=images/back-to.gif border=0><font face=verdana size=2>  Back to Add Category Record</font></a></center>";
        include_once("your-footer.inc");
	exit();	
}

$conn = @mysql_connect($server,$user,$password)
	or die("Unable to connect to SQL database...");
$rs = @mysql_select_db($database,$conn) 
	or die("Unable to select the database ...Please press 'Create Database' to create new database.");
$sql = " SELECT category,catid from $table where catid = $catid";
$rs = @mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
while ($row = mysql_fetch_array($rs))
{
       echo("<center><font face=verdana size=2>Category: </font>".$row["category"]); 
       echo("<br></center><center><font face=verdana size=2>Category ID:</font>".$row["catid"]);
       echo("<br><font face=verdana size=2>Already exists in Category table e.g category id '$catid'!</font><br></center>");
       echo("<br><center><img src=images/line.gif border=0 width=450 height=1><br></font face=verdana size=2>Press 'Back' button to return to previous menu. </font><br><img src=images/line.gif border=0 width=450 height=1></center><br><br>");
echo "<center><a href=show_addrecord3.html><img src=images/back-to.gif border=0><font face=verdana size=2>  Back to Add Category Record</font></a></center>";
        include_once("your-footer.inc");
       exit();
}
$sql = "INSERT INTO $table (category,catid,cpic)
	VALUES ('$category','$catid','$cpic')";
//echo($sql);
?>
<?
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't add record.");

if (!$sql_result) {     
	echo "<P>Couldn't add record!";
} else 
{
if ($shipopt == "YES")
{
$table = "shipopts";
$sqls = " SELECT shipitem, shipitemprice from $table where shipitem = '$category'";
$rss = @mysql_query($sqls,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
while ($row = mysql_fetch_array($rss))
{
       $shipitem = $row["shipitem"];
       $shipitemprice = $row["shipitemprice"];
       echo("<br><br><center><img src=images/line.gif border=0 width=400></center><center>"); 
       echo("<br><font face=verdana size=2>Shipping Category: $shipitem</font>");
       echo("<br><font face=verdana size=2>Shipping Price: $shipitemprice</font>");
       echo("<br><font face=verdana size=2>Already exists in Shipping table e.g shipping category '$shipitem'!</font><br>");
       echo("<font face=verdana size=2>Press 'Back' button to return to previous menu. <font></center><center><img src=images/line.gif border=0 width=400></center><br><br></center>");
       include_once("./footer.inc");
       exit();
}

$sql1 = "INSERT INTO $table (shipitem,shipitemprice)
	VALUES ('$category','$shiprate')";

$sql_results = mysql_query($sql1,$conn)
	or die("Couldn't add record.");

if (!$sql_results) 
{     
	echo "<P>Couldn't add shipping record!";
} else 
{
	echo "<br><center><font face=verdana size=2><img src=images/sbullet.gif border=0>Shipping Price & Shipping Category successfully added to Shipping table</font></center><br><center>";
}
}

echo "<p align=center><font face=verdana size=2>Category Record sucessfully added!</font></p>
<table border =0 width=400>
<tr>
<td valign=top><strong><font face=verdana size=2>Category:</font></strong></td>
<td valign=top>$category</td>
</tr>
<tr>
<td valign=top><strong><font face=verdana size=2>Category ID:</font></strong></td>
<td valign=top>$catid</td>
</tr><tr>
<td valign=top><strong><font face=verdana size=2>Category Picture:</font></strong></td>
<td valign=top>$cpic</td>
</tr>
</table>
"; 
}

?>

<center><table width="500" border=1><tr align="justify" class="subtitle"><td>
  <p align="center">
  <img border="0" src="images/database.GIF" width="24" height="24"><font face=Verdana size=1><a href="./create_db.php">Create database</a>&nbsp;
  <img border="0" src="images/database.GIF" width="24" height="24"></font><a href="./delete_db.php"><font face=Verdana size=1>Delete database</font></a><font face="Verdana" size="1">&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24"><a href="./create_menu.php">Create table</a>&nbsp;&nbsp;&nbsp;&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24">&nbsp;
  </font> <a href="./add_menu.php"><font face=Verdana size=1>Add Record </font></a>  
  </p>
  <p align="center">&nbsp;<font face="Verdana" size="1"><img border="0" src="images/Records.GIF" width="24" height="24"></font><a href="./view_menu.php"><font face=verdana size=1>View Records</font></a>&nbsp;
  <font face="Verdana" size="1">&nbsp;&nbsp;&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24"></font><a href="./del_menu.php"><font face=verdana size=1>Delete Record</font></a>
  <font face="Verdana" size="1">&nbsp;&nbsp;&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24"></font> <a href="./upd_menu.php"><font face=verdana size=1>Update Record</font></a>&nbsp;
  <img border="0" src="images/home-to.GIF" width="24" height="24"><font face=verdana size=1>&nbsp; <a href="./index.php">Home</a></font>  </a></td></tr></table><br></center>
<img src=images/line.gif border=0 width=100%><br><br>
<?php include("./your-footer.inc");?>
</BODY>
</HTML>
