<html>
<head><title>EZ Shopper - Delete a stock record</title></head>
<body>
<?php
/***************************************************************************
 *			del_stock.php                                      *
 *                     	          				           *
 *   File Info:		  Delete stock record                              *
 *   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 "<p align=\"center\"><br><br><center><img src=images/line.gif border-0 width=100%></center><b><br><center><strong><font face = Verdana size = 2 color=navy>You must login as administrator to use this function!</strong></font></b><br>Click here to return to log in screen <a href='reglog.php'>here.</a><br><br><img src=images/line.gif border=0 width=100%><br><br><br><br></p>";
	include("./your-footer.inc");  
	exit();
}
$pid = getenv("QUERY_STRING");
if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
        $choice = addslashes($_POST["choice"]);
        $delete = addslashes($_POST["delete"]);

}
if ($delete == "delete" and $choice == "NO")
{
echo "<br><center><img src=images/computer.gif border=0><font face=verdana size=3 color=navy>Deleting Stock Record from Stocks Table</font></center><br>";

echo "<center><img src=images/line.gif border=0 width=500></center><center><b><br><font face=verdana size=2>NOTE:- </font></b><font face=verdana size=2>Stock record id  '$pid' not deleted from Stocks table</font></center>";
echo "<br><center><font face=verdana size=2>Return back to <b><a href=./prodstocks.php>products/stocks menu</font></a></b>";
echo "<center><font face=verdana size=2>Return back to <b><a href=./products_edit.php>edit/delete products menu</font></a></b><br><br><center><img src=images/line.gif border=0 width=500></center>";
}
if ($delete =="delete" and $choice =="YES")
{

echo "<br><center><img src=images/computer.gif border=0><font face=verdana size=3 color=navy>Deleting Stock Record from Stocks Table</font></center><br>";

$table = "stocks";
$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 = "DELETE from $table where pid = $pid";
$rs = mysql_query($sql,$conn)
	or die("Unable to delete stock record from stocks table....");
if ($rs)
echo "<center><img src=images/line.gif border=0 width=500></center><center><br><center><font face=verdana size=2>Stock record id  '$pid' successfully deleted from stocks table</font></center>";
echo "<br><center><font face=verdana size=2>Return back to <b><a href=./prodstocks.php>products/stocks menu</font></a></b>";
echo "<center><font face=verdana size=2>Return back to <b><a href=./products_edit.php>edit/delete products menu</font></a></b><br><br><center><img src=images/line.gif border=0 width=500></center>";
}
if ($delete == NULL)
{
echo "<img src=images/line.gif border=0 width=100%><center><br><img src=images/computer.gif border=0><font face=verdana size=3 color=navy>Delete a stock item</font></center><br><center><table width=275 border=1 cellspacing=0 cellpadding=0 height=80>
<tr><td width=275 bgcolor=#CCCCCC height=10>$header</td></tr>
<tr><td width=275 bgcolor=#CCDDFF height=80>";

echo "<form action =./del_stock.php?$pid method = post><center><font face=verdana size=2>Delete stock record with Stock ID = $pid </font><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><font face=verdana size=2>Press 'GO' and select 'YES' to delete stock record.</font></center><img src=images/line.gif border=0 width=100%><br>";
echo "<br><center><font face=verdana size=2>Return back to <b><a href=./prodstocks.php>products/stocks menu</font></a></b>";
echo "<center><font face=verdana size=2>Return back to <b><a href=./products_edit.php>edit/delete product menu</font></a></b>";
}
include_once("./footer.inc");
?>
</body>
</html>