hi i need help i'm trying to build a web page where i can add products to a website (autodidact study project) every things goes right i had my message for adding successfully but when i check the products list or the PHPmyadmin their is no new product plz help
here is the code
<?php
require_once('../mysql.con.php');
/*---Add product to DB---*/
if(isset($_POST['sub']))
{
if ($_FILES['photo']['error']==0)
{
copy($_FILES['photo']['tmp_name'] , "../images".$_FILES['photo']['name']);
}
if($_FILES['photo']['error']==0){
$addtask="INSERT INTO products SET ref='".$_POST['ref']."' , brand='".$_POST['brand']."' , description='".$_POST['desc']."' , idfamily='".$_POST['type']."' , price_ht='".$_POST['price']."' , promo='".$_POST['promo']."' , photo='".$_FILES['photo']['name']."' ";
}else{
$addtask="INSERT INTO products SET ref='".$_POST['ref']."' , brand='".$_POST['brand']."' , description='".$_POST['desc']."' , idfamily='".$_POST['type']."' , price_ht='".$_POST['price']."' , promo='".$_POST['promo']."' ";
}
mysql_query($addtask);
header("location:products.php?add=ok&ref=".$_POST['ref']."");
}
/*---select family---*/
$famtask="SELECT * FROM family";
$faquery=mysql_query($famtask);
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Administration ADD product</title>
<link rel="stylesheet" type="text/css" href="styles/style.admin.css"/>
</head>
<body>
<div id="cont">
<div id="header">
<h1>FashonCom Administration _Back-office_</h1>
</div>
<div id="menu">
<a href="index.php">Home</a> <a href="products.php">Products</a> <a href="addp.php">Add Product</a> <a href="#">Link4</a>
</div>
<div id="content">
<form name="add" id="add" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p> <label for="ref">REF </label> <input type="text" id="ref" name="ref" /></p>
<p><label for="brand"> brand </label> <input type="text" name="brand" id="brand" /> </p>
<p><label for="desc">description </label> </p><textarea rows="10" cols="30" name="desc" id="desc"></textarea>
<p><label for="type">Type </label> <select name="type" id="type"> <?php while($family=mysql_fetch_array($faquery)){ ?>
<option value="<?php echo $family['id']; ?>" ><?php echo $family['family']." ".$family['sexe']; ?></option>
<?php } ?> </select></p>
<p> <label for="price">Price </label> <input type="text" id="price" name="price" /></p>
<p> <label for="size">Size </label> <input type="text" id="size" name="size" /></p>
<p> <label for="promo">Promo </label> <input type="text" id="promo" name="promo" /></p>
<input type="file" name="photo" />
<p><input type="submit" name="sub" value="Add new product"/></p>
</form>
</div>
<div id="footer">
<small>FashionCom administration Copyrights Chalnark 2012</small>
</div>
</div>
</body>
</html>