<html>
<head><title>EZ Shopper - Edit shipping options</title>
<body>
<?php
/***************************************************************************
 *			edit_shipopts.php                                  *
 *                     	          				           *
 *   File Info:		  Edit Shipping Options Menu                       *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
***************************************************************************/

include_once("./header.inc");
include_once("./config.php");
@session_start();
$shipcat = getenv("QUERY_STRING");
$shipcat = str_replace("%20"," ",$shipcat);

if ($admin != "admin" or $admin == NULL)
{
	 echo "<p align=\"center\"><b><strong><font face = Verdana size = 5>Sorry you not the administrator!</strong></font></b><br>Click here to return to log in screen <a href='shop_showall.php'>here.</a><br><br><br><br><br><br></p>";
	include("./your-footer.inc");  
	exit();
}
 if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
	$choice = addslashes($_POST["choice"]);
        $shipcat = addslashes($_POST["shipitem"]);
	$shiprate = addslashes($_POST["shiprate"]);
	$shiprate = number_format($shiprate,2);
}
$strs = getenv("QUERY_STRING");

if ($choice == "edit")
{
$table="shipopts";
echo "<center><h2><center><img src=./images/computer1.gif border=0>Updating a Record to CATEGORY</center></h2></center>";
$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.");
echo("<hr width=500><center>Updating shipping category record with category = ");
echo($shipcat);
echo("<br>");
$done = "FALSE";
$sql = " SELECT shipitem,shipitemprice from $table where shipitem = '$shipcat'";
$rs = @mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
while($row=mysql_fetch_array($rs))
{
       $shipitem = $row["shipitem"];
       $shipitemprice = $row["shipitemprice"];
       $shipitemprice = number_format($shipitemprice,2);
       echo("Shipping category: $shipitem"); 
       echo(" Shipping Price: $shipitemprice");
       echo "<br>New Shipping Price: $shiprate";
       echo("<br><img src=./images/window.gif border=0>Successfully updated the shipping record.....<hr width=500></center>");
    
echo "<br><center>Return back to <b><a href=./shipopts.php>shipping options menu</a><br><br>";
       $done = "OK";
if ($done == "OK")
{
	
	### update shipping item price in shipping table ###

	if ($shipopt == "YES")
	{
		$table = "shipopts";
		$upds = "UPDATE $table set shipitemprice = $shiprate where shipitem = '$shipcat'";
		$rs = @mysql_query($upds,$conn)
			or die("SQL command failed - unable to update shipping record!!!");
		if ($rs)
			echo "<img src=./images/window.gif border=0><font face=verdana color = #000080>Successfully updated the shipping record.....</font>";
	}
	include_once("./footer.inc");
	exit();
}
}
if ($done=="FALSE")
{
	echo("Opps...its seems cannot update category record with category id = ");
	echo($catid);
	exit();
}
}
############## display the text boxes with data ###############

if ($choice == NULL)
{
$table = "shipopts";
$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.");

#### read ship item price from shipping table ####

$table = "shipopts";
$shipcat = str_replace("%20"," ",$shipcat);


$sqls = "SELECT * from $table where shipitem = '$shipcat'";
$rst = @mysql_query($sqls,$conn)
	or die("SQL command failed - unable to get shipping price details!!!");

$rows = @mysql_fetch_array($rst);
$shiprate = $rows["shipitemprice"];
$shiprate = number_format($shiprate,2);
$shipitem = $rows["shipitem"];

$form = "<form method=post action=edit_shipopts.php>";
	$form.= "<table align=center width=400 cellspacing=0 border=1>";
	$form.="<tr><td colspan=2 bgcolor=#ccddff><b>Edit Shipping Option:<b></td></tr>";
	$form.="<tr><td width=150><b>Shipping Category</b></td><td width = 250><input type=text class=textbox name=shipitem size=50 maxlength=100 value='$shipitem' readonly></td></tr>";
	if ($shipopt == "YES")
	$form.="<tr><td width=150><b>Fixed Shipping Rate </b></td><td width = 250><input type=text class=textbox name=shiprate size=10 maxlength=15 value=$shiprate></td></tr>";
	$form.="<tr><td width=150>&nbsp;</td><td width=250><input type=submit value='Edit Category'><input type = reset value = 'Clear'></td></tr>";
	$form.="<input type = hidden name=choice value='edit'>";
	$form.="</table></form>";
	echo $form;
	if ($shipopt == "YES")
		echo "<center><font face=verdana size=2 color = navy>The value of fixed shipping rate is determined by administrative costs for posting.<br>The value is dependent on postage costs from your host country and may vary accordingly.</center><br></font>";
	echo "<center>Return back to <b><a href=./categorys.php>category menu</a></b>";
}

include_once("./footer.inc");

?>
</body>
</html>