par
yllan » 03 nov. 2010, 12:55
je suis passe en mode sq...l rrrrrr : ) je me suis dit que ca devrait etre bon avec ce code :
<?php
error_reporting(E_ALL | E_STRICT);
function upload($index,$destination,$maxsize=FALSE,$extensions=FALSE)
{
//Test1: fichier correctement uploadé
if (!isset($_FILES[$index]) || $_FILES[$index]['error'] > 0)
{
return FALSE;
}
//Test2: taille limite
if ($maxsize !== FALSE && $_FILES[$index]['size'] > $maxsize)
{
return FALSE;
}
//Test3: extension
$ext = substr(strrchr($_FILES[$index]['name'],'.'),1);
if ($extensions !== FALSE && !in_array($ext,$extensions))
{
return FALSE;
}
//Déplacement
return move_uploaded_file($_FILES[$index]['tmp_name'],$destination);
}
if(isset($_POST["Modifier"]))
{
echo("<pre>\n");
var_dump($_POST);
echo("</pre>\n");
try
{
$bdd = new PDO('mysql:host=localhost;dbname=eliate', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$id = $_POST['id'];
$categorie = $_POST['categorie'];
$sscategorie = $_POST['sscategorie'];
$accueil = $_POST['accueil'];
$focus = $_POST['focus'];
$nom = $_POST['nom'];
$ref = $_POST['ref'];
$intro = $_POST['intro'];
$description = $_POST['description'];
$prix = $_POST['prix'];
$dossier = $_POST['dossier'];
$photo01 = $_POST['photo01'];
$photo02 = $_POST['photo02'];
$photo03 = $_POST['photo03'];
$photo04 = $_POST['photo04'];
try
{
$req = $bdd->prepare('UPDATE produits SET
categorie =:nvcategorie ,
sscategorie =:nvsscategorie,
accueil =:nvaccueil,
focus =:nvfocus,
nom =:nvnom,
ref =:nvref,
intro =:nvintro,
description =:nvdescription,
prix =:nvprix,
dossier =:nvdossier,
photo01 =:nvphoto01,
photo02 =:nvphoto02,
photo03 =:nvphoto03,
photo04 =:nvphoto04
WHERE id =:nvid
');
$req->execute(array(
'nvcategorie' => $categorie,
'nvsscategorie' => $sscategorie,
'nvaccueil' => $accueil,
'nvfocus' => $focus,
'nvnom' => $nom,
'nvref' => $ref,
'nvintro' => $intro,
'nvdescription' => $description,
'nvprix' => $prix,
'nvdossier' => $dossier,
'nvphoto01' => $photo01,
'nvphoto02' => $photo02,
'nvphoto03' => $photo03,
'nvphoto04' => $photo04,
'nvid' => $id
));
}
catch(PdoException $e)
{
die('Erreur : '.$e->getMessage());
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$destination = "../produits/";
//EXEMPLES
chmod("../produits/$dossier", 0777);
$upload1 = upload("photo1", "../$photo01", 10485760, FALSE );
$upload2 = upload("photo2", "../$photo02", 10485760, FALSE );
$upload3 = upload("photo3", "../$photo03", 10485760, FALSE );
$upload4 = upload("photoplus", "../$photo04", 10485760, FALSE );
if (!$bdd)
{
die('Requête invalide : ' . mysql_error());
}
else
{
//Si tout va bien, on informe que la modification est faite
echo '
<table align="center" width="800" height="400" bgcolor="#efe8cc">
<tr>
<td align="center" valign="top">
<br><br>
<table width="600" height="400">
<tr>
<td valign="top" width="720" align="center">
<font style="color:#CC3300; font-family:Arial, Helvetica, sans-serif; font-size:24px; font-weight:bold">
VOUS AVEZ BIEN MODIFIER LE PRODUIT<br><br>
</font>
<font style="color:#CC3300; font-family:Arial, Helvetica, sans-serif; font-size:20px; font-weight:bold">
<a href=admin.php>Revenir à l\'administration.</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
';
}
//On ferme if(isset($_POST["Modifier"]))
}
?>
et ben non... je clique sur modifier , le sql me renvoi ca :
array(17) {
["categorie"]=>
string(6) "Bijoux"
["nom"]=>
string(9) "Serpentin"
["sscategorie"]=>
string(6) "Bagues"
["accueil"]=>
string(4) "Luxe"
["focus"]=>
string(3) "Oui"
["ref"]=>
string(9) "BagSer001"
["intro"]=>
string(8) "modifier"
["dossier"]=>
string(9) "BagSer001"
["MAX_FILE_SIZE"]=>
string(8) "10485760"
["photo01"]=>
string(29) "produits/BagSer001/photo1.jpg"
["photo02"]=>
string(29) "produits/BagSer001/photo2.jpg"
["photo03"]=>
string(25) "produits/BagSer001/photo3"
["photo04"]=>
string(28) "produits/BagSer001/photoplus"
["description"]=>
string(8) "modifier"
["prix"]=>
string(2) "20"
["id"]=>
string(2) "12"
["Modifier"]=>
string(8) "Modifier"
}
et rien ne se modifie encore : (
je suis passe en mode sq...l rrrrrr : ) je me suis dit que ca devrait etre bon avec ce code :
[php]
<?php
error_reporting(E_ALL | E_STRICT);
function upload($index,$destination,$maxsize=FALSE,$extensions=FALSE)
{
//Test1: fichier correctement uploadé
if (!isset($_FILES[$index]) || $_FILES[$index]['error'] > 0)
{
return FALSE;
}
//Test2: taille limite
if ($maxsize !== FALSE && $_FILES[$index]['size'] > $maxsize)
{
return FALSE;
}
//Test3: extension
$ext = substr(strrchr($_FILES[$index]['name'],'.'),1);
if ($extensions !== FALSE && !in_array($ext,$extensions))
{
return FALSE;
}
//Déplacement
return move_uploaded_file($_FILES[$index]['tmp_name'],$destination);
}
if(isset($_POST["Modifier"]))
{
echo("<pre>\n");
var_dump($_POST);
echo("</pre>\n");
try
{
$bdd = new PDO('mysql:host=localhost;dbname=eliate', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$id = $_POST['id'];
$categorie = $_POST['categorie'];
$sscategorie = $_POST['sscategorie'];
$accueil = $_POST['accueil'];
$focus = $_POST['focus'];
$nom = $_POST['nom'];
$ref = $_POST['ref'];
$intro = $_POST['intro'];
$description = $_POST['description'];
$prix = $_POST['prix'];
$dossier = $_POST['dossier'];
$photo01 = $_POST['photo01'];
$photo02 = $_POST['photo02'];
$photo03 = $_POST['photo03'];
$photo04 = $_POST['photo04'];
try
{
$req = $bdd->prepare('UPDATE produits SET
categorie =:nvcategorie ,
sscategorie =:nvsscategorie,
accueil =:nvaccueil,
focus =:nvfocus,
nom =:nvnom,
ref =:nvref,
intro =:nvintro,
description =:nvdescription,
prix =:nvprix,
dossier =:nvdossier,
photo01 =:nvphoto01,
photo02 =:nvphoto02,
photo03 =:nvphoto03,
photo04 =:nvphoto04
WHERE id =:nvid
');
$req->execute(array(
'nvcategorie' => $categorie,
'nvsscategorie' => $sscategorie,
'nvaccueil' => $accueil,
'nvfocus' => $focus,
'nvnom' => $nom,
'nvref' => $ref,
'nvintro' => $intro,
'nvdescription' => $description,
'nvprix' => $prix,
'nvdossier' => $dossier,
'nvphoto01' => $photo01,
'nvphoto02' => $photo02,
'nvphoto03' => $photo03,
'nvphoto04' => $photo04,
'nvid' => $id
));
}
catch(PdoException $e)
{
die('Erreur : '.$e->getMessage());
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$destination = "../produits/";
//EXEMPLES
chmod("../produits/$dossier", 0777);
$upload1 = upload("photo1", "../$photo01", 10485760, FALSE );
$upload2 = upload("photo2", "../$photo02", 10485760, FALSE );
$upload3 = upload("photo3", "../$photo03", 10485760, FALSE );
$upload4 = upload("photoplus", "../$photo04", 10485760, FALSE );
if (!$bdd)
{
die('Requête invalide : ' . mysql_error());
}
else
{
//Si tout va bien, on informe que la modification est faite
echo '
<table align="center" width="800" height="400" bgcolor="#efe8cc">
<tr>
<td align="center" valign="top">
<br><br>
<table width="600" height="400">
<tr>
<td valign="top" width="720" align="center">
<font style="color:#CC3300; font-family:Arial, Helvetica, sans-serif; font-size:24px; font-weight:bold">
VOUS AVEZ BIEN MODIFIER LE PRODUIT<br><br>
</font>
<font style="color:#CC3300; font-family:Arial, Helvetica, sans-serif; font-size:20px; font-weight:bold">
<a href=admin.php>Revenir à l\'administration.</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
';
}
//On ferme if(isset($_POST["Modifier"]))
}
?>
[/php]
et ben non... je clique sur modifier , le sql me renvoi ca :
[sql]
array(17) {
["categorie"]=>
string(6) "Bijoux"
["nom"]=>
string(9) "Serpentin"
["sscategorie"]=>
string(6) "Bagues"
["accueil"]=>
string(4) "Luxe"
["focus"]=>
string(3) "Oui"
["ref"]=>
string(9) "BagSer001"
["intro"]=>
string(8) "modifier"
["dossier"]=>
string(9) "BagSer001"
["MAX_FILE_SIZE"]=>
string(8) "10485760"
["photo01"]=>
string(29) "produits/BagSer001/photo1.jpg"
["photo02"]=>
string(29) "produits/BagSer001/photo2.jpg"
["photo03"]=>
string(25) "produits/BagSer001/photo3"
["photo04"]=>
string(28) "produits/BagSer001/photoplus"
["description"]=>
string(8) "modifier"
["prix"]=>
string(2) "20"
["id"]=>
string(2) "12"
["Modifier"]=>
string(8) "Modifier"
}
[/sql]
et rien ne se modifie encore : (