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
|
<?php
require_once('../includes/connexion.php');
session_start();
if (!isset($_SESSION['login']))
{
exit();
}
include('../includes/header.php');
if (isset($_POST['submit']))
{
$idCat = $_POST["idCat"];
$titreArticle = htmlspecialchars($_POST["titreArticle"]);
$contenuArticle = htmlspecialchars($_POST["contenuArticle"]);
$photoArticle = $_FILES["photoArticle"];
$descPhoto = htmlspecialchars($_POST["descPhoto"]);
addslashes($contenuArticle) && addslashes($titreArticle) && addslashes($descPhoto);
if(!empty($idCat) && !empty($titreArticle) && !empty($contenuArticle) && !empty($photoArticle) && !empty($descPhoto) )
{
$req = 'INSERT INTO articles (idArticle, idCat, titreArticle, contenuArticle, photoArticle, descPhoto) VALUES ("", "'. $idCat .'", "'. $titreArticle .'" , "'. $contenuArticle .'","'. $photoArticle .'", "'. $descPhoto .'");';
$result = mysql_query($req, $connexion) or die(mysql_error());
if ($result)
{
if (isset($_FILES['photoArticle']) AND $_FILES['photoArticle']['error'] == 0)
{
//$chemin = $_FILES['photoArticle']['url'];
// echo $chemin;
//$nomPhoto = 001;
//$nomPhoto = $nomPhoto+1;
$redimOK = fctredimimage(270,0,'../../photos/','.$nomPhoto.','../../../../tmp/','.$photoArticle.');
if ($redimOK == 1)
{
echo 'Redimensionnement OK !';
}
}
echo '<div class="valide"><p>L\'ajout a été correctement effectué.</p></div>' ;
}
else
{
echo '<div class="echec"><p> L\'ajout a échoué.</p></div>';
}
}
else echo '<div class="echec"><p> Vous n\'avez pas rempli tous les champs. </p></div>';
}
include('../includes/form_ajoutarticle.php');
include('../includes/footer.php');
mysql_close($connexion);
?> |
Partager