1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
| <?php
if(isset($_POST['nom_prod'])){
$product_name= mysql_real_escape_string($_POST['nom_prod']);
$price= mysql_real_escape_string($_POST['prix']);
$details= mysql_real_escape_string($_POST['details']);
$category= mysql_real_escape_string($_POST['category']);
$subcategory= mysql_real_escape_string($_POST['subcategory']);
$sql2= mysql_query("select ref from produits where nom_prod='$product_name' LIMIT 1");
$productMatch= mysql_num_rows($sql2);
if($productMatch>0){
echo'Sorry you tried to place a duplicate "Product Name" into the system,<a href="inventory_list.php">Click here</a>';
exit();
}
$sql= mysql_query("Insert into produits (nom_prod,prix,details,category,subcategory,date_added) values ('$product_name','$price','$details','$category','$subcategory',row())") or die(mysql_error());
$pid= mysql_insert_id();
$newname="$pid.jpg";
move_uploaded_file($_FILES['fileField']['tmp_name'], "inventory_images/$newname");
header("location:inventory_list.php");
exit();
}
?>
<?php
$product_list="";
$sql= mysql_query("select * from produits order by date_added DESC");
$producCount= mysql_num_rows($sql);
if($producCount>0){
while($row= mysql_fetch_array($sql)){
$ref=$row["ref"];
$product_name=$row["nom_prod"];
$date_added=strftime("%b %d, %Y",strtotime($row["date_added"]));
$product_list="$date_added - $ref - $product_name <a href='#'>Edit</a> • <a href='#'>Delete</a><br/>";
}
} else {
$product_list="You have no procucts listed in you store yet";
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Inventory_list</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
<link rel="stylesheet" type="text/css" href="style/style.css" media="all" />
</head>
<body>
<div align="center" id="mainWrapper">
<?php include_once 'template_header.php'; ?>
<div id="pageContent"><br/>
<div align="right" style="margin-right:32px;"><a href="inventory_list.php#inventoryFrom">+Add New Inventory Item</a></div>
<div align="left" style="margin-left:24px;">
<h2>Inventory list</h2>
<?php echo $product_list; ?>
</div>
<a name="inventoryFrom" id="inventoryFrom"></a>
<h3>↓Add New Inventory Item Form ↓</h3>
<form action="inventory_list.php" enctype="multipart/form-data" name="myForm" id="myForm" method="post">
<table width="90%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="20%">Product Name</td>
<td width="80%">
<label>
<input name="product_name" type="text" id="product_name" size="64"/>
</label>
</td>
</tr>
<tr>
<td>Product Price</td>
<td>
<label>
<input name="prix" type="text" id="prix" size="12" />$
</label>
</td>
</tr>
<tr>
<td>Catecory</td>
<td>
<label>
<select name="category" id="category">
<option value="Séléctionner">Séléctionner</option>
<option value="Clothing">Clothing</option>
<option value="Electronics">Electronics</option>
</select>
</label>
</td>
</tr>
<tr>
<td>SubCatecory</td>
<td>
<select name="subcatecory" id="subcatecory">
<option value="Séléctionner">Séléctionner</option>
<option value="Hats">Hats</option>
<option value="Pants">Pants</option>
<option value="Shirts">Shirts</option>
</select>
</td>
</tr>
<tr>
<td>Product Details</td>
<td>
<label>
<textarea name="details" id="details" clos="64" rows="5"></textarea>
</label>
</td>
</tr>
<tr>
<td>Product Image</td>
<td>
<label>
<input type="file" name="fileField" id="fileField" />
</label>
</td>
</tr>
<tr>
<td> </td>
<td>
<label>
<input type="submit" name="button" id="button" value="Add this Item Now" />
</label>
</td>
</tr>
</table>
</form>
<br/><br/><br/>
</div>
<?php include_once 'template_footer.php'; ?>
</div>
</body>
</html> |
Partager