<html>
<head><title>EZ Shopper - Delete shipping option</title></head>
<body>
<?php
/***************************************************************************
 *			del_shipopts.php                                   *
 *                     	          				           *
 *   File Info:		  Delete shipping option                           *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/

include_once("./header.inc");
include_once("./config.php");
@session_start();
if ($_SESSION['admin'] != "admin" or $_SESSION['admin'] == NULL)
{
echo "<br><br><center><img src=images/line.gif border=0 height=1 width=400></center><p align=\"center\"><img src=images/keybord1.gif border=0><b><strong><font face = Verdana size = 3>   Sorry you are not the administrator!</strong></font></b><br>Click here to return to log in screen  <a href='shop_showall.php'>here.</a>
<br><br><img src=images/line.gif border=0 height=1 width=400><br><br><br><br></p>";
	include("./your-footer.inc");  
	exit();
}
$shipcat = getenv("QUERY_STRING");
$shipcat = str_replace("%20"," ",$shipcat);
if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
        $choice = addslashes($_POST["choice"]);
        $delete = addslashes($_POST["delete"]);
	$shipcat = addslashes($_POST["shipcat"]);
	$shipcat = str_replace("%20"," ",$shipcat);
}
if ($delete == "delete" and $choice == "NO")
{
echo "<br><center><img src=images/computer1.gif border=0><font face=verdana size=2 color=navy> Deleting Shipping Record from ShippingTable</center><br>";
echo "<center><img src=images/line.gif border=0 width=400 height=1></center><br><center>Shipping record '$shipcat' not deleted from shipping table</center>";

echo "<br><center>Return back to <b><a href=./shipopts.php>shipping options menu</a></b></font><br><br><img src=images/line.gif border=0 width=400 height=1></center>";
}
if ($delete =="delete" and $choice =="YES")
{
echo "<br><center><img src=images/computer1.gif border=0><font face=verdana size=2 color=navy> Deleting Category Record from Category Table</center><br>";
$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.");

##### Also delete shipping record if exists ! #####

if ($shipopt == "YES")
{

$table = "shipopts";
$sqls = "DELETE from $table where shipitem = '$shipcat'";
$rst = mysql_query($sqls,$conn);
	
if ($rst)
echo "<br><center><img src=images/line.gif border=0 width=400 height=1></center><br><center><font face=verdana size=2 color=navy>Shipping record $shipcat successfully deleted from shipping table</center>";
if (!$rst)
	echo("<center>Unable to delete shipping record from shipping table....<br>Possibly shipping record has already been deleted!</center>");
}

echo "<br><center>Return back to <b><a href=./shipopts.php>shipping options menu</a></b></font><br><br><img src=images/line.gif border=0 width=400 height=1></center>";
}
if ($delete == NULL)
{
echo "<center><table width=450 border=1 cellspacing=0 cellpadding=0 height=80>
<tr><td width=450 bgcolor=#CCCCCC height=10>$header</td></tr>
<tr><td width=450 bgcolor=#CCDDFF height=80>";

if ($shipopt == "NO")
echo "<form action =./del_shipopts.php?$shipcat method = post><center>Delete shipping option = $shipcat <input type=hidden name=delete value='delete'><select name = \"choice\"><option value=\"YES\">-- YES --</option><option value = \"NO\">-- NO --</option></select><input type=submit name = submit value='GO'></form></tr></table><br>Press 'GO' and select 'YES' to delete shipping option.</center>";
if ($shipopt == "YES")
$shipcats = str_replace(" ","%20",$shipcat);
echo "<form action =./del_shipopts.php?$shipcats method = post><center><br><font face=verdana size=2 color =navy>Delete shipping category = $shipcat</font><br><br> <input type=hidden name=delete value='delete'><select name = \"choice\"><option value=\"YES\">-- YES --</option><option value = \"NO\">-- NO --</option></select><input type=submit name = submit value='GO'><input type=hidden name=shipcat value=$shipcats></form></tr></table><br>Press 'GO' and select 'YES' to delete  shipping record!</center>";

echo "<br><center>Return back to <b><a href=./shipopts.php>shipping options menu</a></b></font><br><br><img src=images/line.gif border=0 width=400 height=1></center>";

echo "<br><p align=justify><img src=./images/bullets.gif border=0><font face=verdana size=2 color = darkgreen> Note: If you delete a shipping record from the shipping table, you will not be able to create the shipping record until you delete the associated category. Please delete the category from Edit/Delete categories menu and then add the category and fixed shipping rate details from Add Categories menu.</font></p>";
}
include_once("./footer.inc");
?>
</body>
</html>