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
| if (isset($_POST['sent']))
{
$titreoeuvre=$_POST['titre_oeuvre'];
$descriptionoeuvre=$_POST['description_oeuvre'];
$categorie=$_POST['oeuvre_categorie'];
$style=$_POST['oeuvre_style'];
$date_crea=$_POST['date_crea'];
if ($_FILES['image_oeuvre']['name']!=NULL)
{
$imageoeuvre=$_FILES['image_oeuvre']['name'];
$ext = strtolower(pathinfo($imageoeuvre,PATHINFO_EXTENSION));
$allow_ext = array('jpg','png','gif','bmp','jpeg');
if (!empty($imageoeuvre))
{
if (in_array($ext,$allow_ext))
{
$destination ="./images/oeuvres/".$imageoeuvre;
move_uploaded_file($_FILES['image_oeuvre']['tmp_name'],$destination);
$artiste_id=$_SESSION['membre_id'];
$req = $bdd->prepare('UPDATE oeuvre_artiste SET image_oeuvre=:image_oeuvre WHERE artiste_id=:artiste_id AND oeuvre_id=:oeuvre_id');
$req->bindValue(':image_oeuvre', $imageoeuvre, PDO::PARAM_STR);
$req->bindValue(':artiste_id', $artiste_id, PDO::PARAM_INT);
$req->bindValue(':oeuvre_id', $oeuvre_id, PDO::PARAM_INT);
$req->execute();
}
else
{
echo '<p class="texteerror">'."Votre fichier contient une mauvaise extension, ou n'est pas une image.".'</p>';
}
}
else
{
$imageoeuvre = '';
}
}
if ( (!empty($imageoeuvre)) OR (!empty($titreoeuvre)) OR (!empty($descriptionoeuvre)) OR (!empty($categorie)) OR (!empty($style)) OR (!empty($datecreaoeuvre)) )
{
try {
$artiste_id=$_SESSION['membre_id'];
$query2 = $bdd->prepare('UPDATE oeuvre_artiste SET artiste_id=:artiste_id, oeuvre_id=:oeuvre_id, titre_oeuvre=:titre_oeuvre, description_oeuvre=:description_oeuvre, oeuvre_categorie=:oeuvre_categorie, oeuvre_style=:oeuvre_style, date_crea=:date_crea WHERE oeuvre_id=:oeuvre_id AND artiste_id=:artiste_id');
$query2->bindValue(':artiste_id', $artiste_id, PDO::PARAM_INT);
$query2->bindValue(':oeuvre_id', $oeuvre_id, PDO::PARAM_INT);
$query2->bindValue(':titre_oeuvre', $titreoeuvre, PDO::PARAM_STR);
$query2->bindValue(':description_oeuvre', $descriptionoeuvre, PDO::PARAM_STR);
$query2->bindValue(':oeuvre_categorie', $categorie, PDO::PARAM_STR);
$query2->bindValue(':oeuvre_style', $style, PDO::PARAM_STR);
$query2->bindValue(':date_crea', $date_crea, PDO::PARAM_INT);
$query2->execute();
}
catch (Exception $e)
{
echo 'Erreur : ' . $e->getMessage();
}
echo '<p class="textevalide">'."Votre modification à bien été effectué !".'</p>';
}
}
$query->CloseCursor(); |
Partager