<?php //j'ai une table bidon qui reprend tes champs /* CREATE TABLE IF NOT EXISTS `produit` ( `id` int(11) NOT NULL AUTO_INCREMENT, `reference` varchar(50) NOT NULL, `nomproduit` text NOT NULL, `description` varchar(50) NOT NULL, `prix` float NOT NULL, `idcategorie` varchar(50) NOT NULL, `marque` varchar(50) NOT NULL, `promotion` varchar(5) NOT NULL, `QteStock` int(11) NOT NULL, `Tva` float NOT NULL, `img` longblob NOT NULL, PRIMARY KEY (`id`) ) ENGINE= MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; */ mysql_connect('localhost','root',''); mysql_select_db('blob'); /*ici la tienne*/ if(isset($_GET['voir']) && !empty($_GET['voir'])){ $last=(int)($_GET['voir']); $s=mysql_query("select img from produit where id='".$last."'"); $r=mysql_fetch_array($s); if($r['img']!=""){ $f=list($name,$type,$size,$content)=$r['img']; print_r($f); }else{ //echo "rien"; } }else{ } $msg=""; if (isset($_FILES['img']) && !empty($_FILES['img']['tmp_name']) ){ $data = file_get_contents($_FILES['img']['tmp_name']); $data = mysql_real_escape_string($data); $msg = 'image chargée'; }else{ $data=''; $msg='pas d\'image chargée'; } echo '<center>'.$msg.'</center> '; /*le formulaire est envoyé*/ if(isset($_POST['sub'])){ $_POST['titre']="un titre"; $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']."','".$data."')"; if(mysql_query($sql2)){ echo '<center>LIGNE INSERÉE ['.$_SERVER['PHP_SELF'].' RETOUR AU FORMULAIRE]</center>'; unset($_POST); /*verif image blob*/ $last=mysql_insert_id(); echo '<center><hr>[?voir='.$last.' Verifier + Voir l\'image]</center> '; }else{ exit('ouuu !'); } /*sinon affichage du form*/ }else{?> <!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> <center> Ajouter un nouveau produit <form action="" method="POST" ENCTYPE="multipart/form-data" /> Catégorie |<select name ="titre"> </select>, ---- Réference: |, ---- Nom: |, ---- Description |</th>, ---- Prix: |, ---- Marque: |, ---- Promotion: |, ---- Quantité Stock: |, ---- TVA: |, ---- image: | </form> </center> </html> <?php } ?>
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question