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
| <?php
$con=mysql_connect("localhost","root","") or die ("erreur de connection au serveur");
$db=mysql_select_db("gestioncommande") or die ("erreur de connection a la BD");
$sqlSelectCat="select * from categories";
$resultat=mysql_query($sqlSelectCat);
if (isset($_POST['inserer']))
{
if ($_FILES['photo']['error']==0)
{
copy($_FILES['photo']['tmp_name'],"Photo/".$_FILES['photo']['name']);
$reqInsert="INSERT INTO articles VALUES('".$_POST['ca']."','".$_POST['na']."','".$_POST['pa']."','".$_POST['qt']."','".$_FILES['photo']['name']."','".$_POST['cat']."',)";
}
//on utilise la méthode post pour modifier l'image car elle ne peut pas être contenu dans l'URL de Get
else
{
$reqInsert="insert into articles values ('".$_POST['ca']."','".$_POST['na']."','".$_POST['pa']."','".$_POST['qt']."','photo='photopardefault.jpg','".$_POST['cat']."',)";
}
// on fait le header pour revenir à la page principale
mysql_query($reqInsert);
header('Location:liste_article_selection.php');
}
//pour importer les données de la table categorie
$sqlSelectCat="select * from categories";
$resultat=mysql_query($sqlSelectCat);
?> |
Partager