Bonsoir;
j'ai un probleme...
je travaille coté administrateur...
j'ajout des produits a la base de données avec ses images...
l'ajout de produits marche bien...
mais le probleme est l'image de chaque produit ne s'affiche pas...
*je suis tres nerveux...
aidez moi ..
php:5.3.3.5
la table produit :idproduit int(12) auto_increment
reference varchar(20)
nomprodui tvarchar(20)
description varchar(20)
prix double
idcategorie int(12) clé etrangere de table catégorie
marque varchar(20)
promotion varchar(20)
TVA double
img blob
Voici le code d'ajout:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Ajouter un produit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
include('fonctions.php');
session_start();
if(isset($_SESSION['login'])){
?>
<center>
<h3>Ajouter un nouveau produit</h3>
<form action="ajouter.php" method="POST">
<table border="1" bgcolor="#FF0080">
<tr><th>Catégorie</th><td>
<select name="titre">
<?php
connexion();
$query = 'SELECT * FROM `categorie` WHERE `idcategorie`<>`titre`;';
$result = mysql_query($query) or die("erreur!!");
$i = 0;
while($row = mysql_fetch_row($result)){
$i++;
echo "<option value=\"".$row[0]."\">".$row[1];
}
if($i == 0){
?>
<script type="text/javascript">
alert("aucune categorie disponible!!");
window.location.replace("GestionProduits.php");
</script>
<?php
}
mysql_close();
?>
</select>
</td>
<tr><th>Réference:</th><td><input type="text" name="reference"></td></tr>
<tr><th>Nom:</th><td><input type="text" name="nomproduit"></td></tr>
<tr><th>Description</th>:</th><td><input type="text" name="description"></td></tr>
<tr><th>Prix:</th><td><input type="text" name="prix"></td></tr>
<tr><th>Marque:</th><td><input type="text" name="marque"></td></tr>
<tr><th>Promotion:</th><td><input type="text" name="promotion"></td></tr>
<tr><th>Quantité Stock:</th><td><input type="text" name="QteStock"></td></tr>
<tr><th>TVA:</th><td><input type="text" name="TVA"></td></tr>
<tr><th>image:</th><td><input name="img" type="file"></td></tr>
</table>
<br>
<input type="submit" value="Ajouter"> <input type="reset" value="Effacer">
</form>
</center>
<?php
if(isset($_POST['titre']) and isset($_POST['reference']) and isset($_POST['nomproduit']) and isset($_POST['description']) and isset($_POST['prix'])
and isset($_POST['marque']) and isset($_POST['promotion']) and isset($_POST['QteStock']) and isset($_POST['TVA']) and isset($_POST['img']))
{
if(!empty($_POST['titre']) and !empty($_POST['reference']) and !empty($_POST['nomproduit']) and !empty($_POST['description']) and !empty($_POST['prix'])
and !empty($_POST['marque']) and !empty($_POST['promotion']) and !empty($_POST['QteStock']) and !empty($_POST['TVA']) and !empty($_POST['img']))
{
connexion();
$sql1="select * from produit where reference='".$_POST['reference']."'";
$resultat=mysql_query($sql1) or die('erreur');
if(mysql_num_rows($resultat)==0)
{
$sql2="insert into produit(reference,nomproduit,description,prix,idcategorie,marque,promotion,QteStock,TVA,img) values('".$_POST['reference']."','".$_POST['nomproduit']."','".$_POST['description']."','".$_POST['prix']."',
'".$_POST['titre']."','".$_POST['marque']."','".$_POST['promotion']."','".$_POST['QteStock']."','".$_POST['TVA']."','".$_POST['img']."')";
mysql_query($sql2);
deconnexion();
alerte("Le produit ".$_POST['nomproduit']." est ajouté avec succés");
}
else
alerte('le produit existant');
}
else
alerte('Remplir les champs');
}
?>
</body>
</html>
<?php
}else{
?>
<script language="javascript" type="text/javascript">
<!--
window.location.replace("index.php");
-->
</script>
<?php
}
?>
merci bien