require_once("../database.php");
require_once("adminfuncties.php");
require_once("product_navigatie.php");
if(isset($_POST[s1]))
{
$MyProductName = htmlentities(strip_tags($_POST[ProductName]));
$MyProductName2 = stripslashes($MyProductName);
$NewCategoryInfo = explode("|", $_POST[CategoryInfo]);
$NewDesc = htmlentities(strip_tags($_POST[ProductDesc]));
$NewDesc2 = stripslashes($NewDesc);
$ImageName = $_FILES[ProductImage][name];
$NewShipping = strip_tags($_POST[ShippingPrice]);
$NewPrice = strip_tags($_POST[ProductPrice]);
if(empty($MyProductName))
{
$add_error = "
Wat is de naam van het product?";
}
elseif(empty($_POST[CategoryInfo]))
{
$add_error = "Selecteer een product categorie.";
}
elseif(empty($NewPrice))
{
$add_error = "Wat is de prijs van het product?";
}
else
{
$t = time();
if(!empty($ImageName))
{
$NewImageName = "$t$ImageName";
copy($_FILES[ProductImage][tmp_name], "../items_images/$NewImageName");
}
$q1 = "insert into oneshop_producten set
ItemName = '$MyProductName',
ItemCategory = '$NewCategoryInfo[0]',
ItemSubcategory = '$NewCategoryInfo[1]',
ItemDescription = '$NewDesc',
ItemPrice = '$NewPrice',
ItemShipping = '$NewShipping',
ItemImage = '$NewImageName',
ProductStatus = 'unapproved',
AddDate = '$t' ";
mysql_query($q1) or die(mysql_error());
$qn = mysql_query("select last_insert_id()") or die(mysql_error());
$an = mysql_fetch_array($qn);
$LastID = $an[0];
$q1 = "select CategoryName from oneshop_categories where CategoryID = '$NewCategoryInfo[0]' ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
$DisplayCategory = $a1[0];
if(! empty($NewCategoryInfo[1]))
{
$q2 = "select SubcategoryName from devbg_subcategories where SubcategoryID = '$NewCategoryInfo[1]' ";
$r2 = mysql_query($q2) or die(mysql_error());
$a2 = mysql_fetch_array($r2);
$DisplayCategory .= " / $a2[0]";
}
?>
exit();
}
}
elseif(isset($_POST[s2]))
{
if($_POST[s2] == "Accept")
{
$q1 = "update oneshop_producten set ProductStatus = 'approved' where ItemID = '$_POST[ItemID]' ";
mysql_query($q1) or die(mysql_error());
echo "
Het product werd succesvol toegevoegd.";
}
if($_POST[s2] == "Delete" )
{
mysql_query("delete from oneshop_producten where ItemID = '$_POST[ItemID]' ") or die(mysql_error());
if(!empty($_POST[NewImageName]))
{
unlink("items_images/$_POST[NewImageName]");
}
}
}
$q1 = "select * from oneshop_categories order by CategoryName ";
$r1 = mysql_query($q1);
if(!$r1)
{
header("location:../foutmelding.php");
}
else
{
if(mysql_num_rows($r1) == '0')
{
echo "
U moet eerst minstens één categorie aanmaken voor je een product kunt toevoegen.";
exit();
}
else
{
$MySelect = "";
}
}
?>