<?php
set_magic_quotes_runtime(0);
include ("txt/vars.php");
$link=mysql_connect("$mysqlhost","$mysqllogin","$mysqlpass") or die("Could not connect");
mysql_select_db($mysqldb) or die("Could not select database");
include ("auth_user.php");
$lot=$_POST['lot'];
$lot=mysql_escape_string($lot);
$query="select seller from goods where (first='$lot')";
$res=mysql_query($query);
$row=mysql_fetch_assoc($res);
$seller=$row["seller"];
if (!isset($lot)) {
echo "<center><b>Не указан лот!</b></center>";
echo "<meta http-equiv='refresh' content='2 url=lot.php'>";
exit;
}
if ($crc_username!=$seller) {
echo "<center><b>Вы пытаетесь удалить чужой лот!</b></center>";
echo "<meta http-equiv='refresh' content='2 url=lot.php'>";
exit;
}
$query="select photo from goods where (first='$lot')";
$resphoto=mysql_query($query);
$photorow=mysql_fetch_assoc($resphoto);
$photo_of_good=$photorow["photo"];
if (file_exists("photos/$photo_of_good") && $photo_of_good!="") {
unlink("photos/$photo_of_good");
}
$query="delete from goods where (first='$lot')";
mysql_query($query);
mysql_close ($link);
?>
<script language="JavaScript">
location.href="lots.php";
</script>