Viewing file: Modification categories.php (9.26 KB) -rw----r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
if (isset($_SESSION['identifiant']))
{
$user = $_SESSION['identifiant'];
if ($user)
{
if (isset($_GET['creation']))
{
}
else
{ echo "<table width='540' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td valign='bottom'>
<br><span class='Style6'>Modification des categories</span>
</td>
<td valign='bottom'><div align='right'>
<form action='index.php?page=Modification categories&creation=1' method='POST' enctype='multipart/form-data'>
<input type='submit' name='sup' value='Ajouter une Catégorie'>
</form>
</div></td>
</tr>
</table><p>";
echo ' <form id="form1" name="form1" method="post" action="index.php?page=Modification categories">
<select name="Chapitre">';
if (isset($_POST['select']))
{
$selection = $_POST["Chapitre"];
echo '<option value="">'.$selection.'</option>';
}
else
{
echo '<option value="">----- Chapitre -----</option>';
}
$get = mysql_query("SELECT * FROM articles_chapitre");
while ($row = mysql_fetch_assoc($get))
{
$chapitre = $row['CHAPITRE'];
echo "<option value=".$chapitre.">".$chapitre."</option>";
}
echo '</select>
<input type="submit" value="Go" name="select" />
</form><br>';
}
if (isset($_GET['creation']))
{
$creation = $_GET['creation'];
if ($creation==2)
{
if (isset($_POST['crea']))
{
//récuperer le fichier envoyé
$id = $_POST['Chapitre'];
$cat = $_POST['nomchap'];
$name = $_FILES['myfile']['name'];
$size = $_FILES['myfile']['size']; //voir le tutorial upload pour vérifier que c'est une image
$tmp_name = $_FILES['myfile']['tmp_name'];
if ($name)
{
//Chargement en cours(on commence par configurer la photo (3 lignes)
$cat2 = $cat;
$cat2 = strtr($cat2, 'ÁÀÂÄÃÅÇÉÈÊËÍÏÎÌÑÓÒÔÖÕÚÙÛÜÝ', 'AAAAAACEEEEEIIIINOOOOOUUUUY');
$cat2 = strtr($cat2, 'áàâäãåçéèêëíìîïñóòôöõúùûüýÿ/', 'aaaaaaceeeeiiiinooooouuuuyy_');
$location ="photo_sous_categorie/".$cat2.".png";
$emplacement ="photo_sous_categorie/";
include ("Enregistrement.php");
$chapselect = mysql_query("SELECT * FROM articles_chapitre WHERE ID='$id'");
$row = mysql_fetch_assoc($chapselect);
$chap = $row['CHAPITRE'];
$query = mysql_query("INSERT INTO articles_categorie VALUES ('','$chap','$cat','$location')");
echo("<br><span class='Style5'>La nouvelle catégorie est maintenant enregistré <a href='index.php?page=member'>Retour</a></span><br>");
}
else
echo("Sélectionner un fichier!");
}
}
else
{
//formulaire de creation de chapitre
echo"<form action='index.php?page=Modification categories&creation=2' method='POST' enctype='multipart/form-data'>
<br><span class='Style5'>
<span class='Style6'>Création d'une catégorie</span><p>
<table width='400' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td>Chapitre: </td>
<td>
<select name='Chapitre'>
<option value=''>----- Chapitres -----</option>";
$get = mysql_query('SELECT * FROM articles_chapitre');
while ($row = mysql_fetch_assoc($get))
{
$chapitre = $row['CHAPITRE'];
$id = $row['ID'];
echo "<option value=".$id.">".$chapitre."</option>";
}
echo '</select>
<br><img src="image/transparent.png" width="30" height="4" /></td>
</tr>
<tr>
<td>Nom de la Catégorie: </td>
<td><input type="text" name="nomchap"><br>
<img src="image/transparent.png" width="30" height="4" /></td>
</tr>
<tr>
<td>Image: </td>
<td><input type="file" name="myfile"><br>
<img src="image/transparent.png" width="30" height="4" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="crea" value="Confirmer la création"></td>
</tr>
</table>
</span><p>
</form>
';
}
}
else
{}
if (isset($_GET['choix']))
{
$choix = $_GET['choix'];
if (isset($_GET['supprimer']))
{
$supprimer = $_GET['supprimer'];
if ($supprimer==2)
{
$query = mysql_query("DELETE FROM articles_categorie WHERE SOUSCATEGORIE='$choix'");
echo ("Le chapitre ".$choix." n'existe maintenant plus. <a href='index.php?page=Modification categories'><strong>Retour</strong></a><br>");
}
else
{
echo "<form action='index.php?page=Modification categories&choix=".$choix."&supprimer=2' method='POST' enctype='multipart/form-data'>
Confirmer la suppression de \"".$choix."\"
<input type='submit' name='sup' value='Supprimer'>
</form>";
}
}
else
{
if (isset($_POST['submit']))
{
//récuperer le fichier envoyé
$name = $_FILES['myfile']['name'];
$size = $_FILES['myfile']['size']; //voir le tutorial upload pour vérifier que c'est une image
$tmp_name = $_FILES['myfile']['tmp_name'];
if ($name)
{
//Chargement en cours
$choix2 = $choix;
$choix2 = strtr($choix2, 'ÁÀÂÄÃÅÇÉÈÊËÍÏÎÌÑÓÒÔÖÕÚÙÛÜÝ', 'AAAAAACEEEEEIIIINOOOOOUUUUY');
$choix2 = strtr($choix2, 'áàâäãåçéèêëíìîïñóòôöõúùûüýÿ/', 'aaaaaaceeeeiiiinooooouuuuyy_');
$location ="photo_sous_categorie/".$choix2.".png";
$emplacement ="photo_sous_categorie/";
$cat = $choix;
$cat2 = $choix2;
include ("Enregistrement.php");
$location ="photo_sous_categorie/$choix2.png";
move_uploaded_file($tmp_name,$location); //regarder le tutorial pour que personne ne puisse y installer des fichier!!!
$query = mysql_query("UPDATE articles_categorie SET PHOTO='$location' WHERE SOUSCATEGORIE='$choix'");
echo("L'image est maintenant enregistré <a href='index.php?page=member'>Retour</a><br>");
}
else
echo("Sélectionner un fichier!");
}
else
{
echo "<span class='Style5'>Mettre à jour la photo: \"".$choix."\"<br>
<img src='image/transparent.png' width='30' height='4' /><br>
<form action='index.php?page=Modification categories&choix=".$choix."' method='POST' enctype='multipart/form-data'>
Fichier: <input type='file' name='myfile'> <input type='submit' name='submit' value='Charger'><span>
</form>";
}
}
echo '</span>';
}
else
{}
if (isset($_POST['select']))
{
$selection = $_POST['Chapitre'];
}
else
{
$selection = "12345";
}
//apparition des données
$get = mysql_query("SELECT * FROM articles_categorie WHERE CATEGORIE LIKE '$selection%' ORDER BY SOUSCATEGORIE ASC ");
while ($row = mysql_fetch_assoc($get))
{
// obtenir données
$picture = $row['PHOTO'];
$name = $row['SOUSCATEGORIE'];
echo "
<table width='562' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td> </td>
</tr>
<tr>
<td background='image/article.png'><table width='540' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='120' height='90'><div align='center'><img src='$picture' width='100' height='70' /></div></td>
<td width='407' valign='middle'><div align='left'>
<p align='left' class='Style5'>";
echo"<strong>".$name."</strong>";
// mettre dans l'echo si dessous les options possibles supprimer ou modifier
echo"<br /><br />
<table width='400' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><div align='right' class='Style5'><a href='index.php?page=Modification categories&choix=".$name."'>Modifier l'image</a> | <a href='index.php?page=Modification categories&supprimer=1&choix=".$name."'>Supprimer</a></div></td>
</tr>
</table>
</p>
</p>
</div></td>
</tr>
</table></td>
</tr>
</table>";
}
}
else
echo("Vous devez être connecté.");
}
else
echo("Vous devez être connecté.");
?>
|