Files
resatennis_tyroltenn/www/site_marchand/admin/produit.php

182 lines
4.2 KiB
PHP
Executable File

<?php
session_start();
$ajoutcat=$HTTP_POST_VARS["ajoutcat"];
$supcat=$HTTP_POST_VARS["supcat"];
$nomcat=$HTTP_POST_VARS["nomcat"];
$idcateg=$HTTP_POST_VARS["idcateg"];
$desc=$HTTP_POST_VARS["desc"];
if ($ajoutcat || $supcat)
{
$loguer=$HTTP_POST_VARS["loguer"];
} else {
$loguer=$HTTP_GET_VARS["loguer"];
}
?>
<html>
<head>
<title>Partie Administrateur</title>
</head>
<body>
<?php
if (isset($_SESSION['idadm']))
{
?>
<div align="center">
<table align=center>
<tr align="center">
<td>
<a href="gestcli.php?loguer=oui&<?php print session_name() ?>=<?php print session_id() ?>">Gestion des clients</a>
</td>
<td>
<a href="produit.php?loguer=oui&<?php print session_name() ?>=<?php print session_id() ?>">Gestion des produits</a>
</td>
<td>
<a href="commande.php?loguer=oui&<?php print session_name() ?>=<?php print session_id() ?>">Gestion des commandes</a>
</td>
</tr>
</table>
<table>
<?php
if ($loguer)
{
require("../connexion.php");
$conn = mysql_connect($host, $user, $password);
mysql_select_db($bdd) or die("Impossible d'ouvrir la base de donnee $bdd");
if ($ajoutcat)
{
$requete1 = "insert into categorie (nomcateg,descriptioncateg) values ('$nomcat','$desc')";
$result1=mysql_query($requete1) or die ("Erreur SQL :$requete<br>".mysql_error()."...");
}
if ($supcat)
{
$requete1 = "delete from categorie where idcateg='$idcateg'";
$result1=mysql_query($requete1) or die ("Erreur SQL :$requete<br>".mysql_error()."...");
}
$requete = "select idcateg,nomcateg,descriptioncateg from categorie order by idcateg";
$result=mysql_query($requete) or die ("Erreur SQL :$requete<br>".mysql_error()."...");
?>
<tr align="center">
<td colspan=2>
<br><br>
<br><br>
<h3><b>Ajouter une categorie</b></h3>
</td>
</tr>
<form name="ajoutcateg" action="produit.php" method="POST">
<tr align="center">
<td align="right">
Nom :
</td>
<td>
<input type=text name="nomcat"/>
</td>
</tr>
<tr align="center">
<td align="right">
Description :
</td>
<td>
<textarea name="desc"></textarea>
<input type="hidden" name="ajoutcat" value="go"/>
<input type="hidden" name="loguer" value="oui"/>
<input type="hidden" name="<?php print session_name() ?>" value="<?php print session_id()?>"/>
</td>
</tr>
<tr align="center">
<td colspan=2>
<input type="submit" value="Ajouter"/>
</td>
</tr>
</form>
<tr>
<td align="center" colspan=2>
<br><br>
<br><br>
<h3><b>Categorie</b></h3>
<table>
<tr bgcolor=#FFFFFF align="center">
<td>
<b>ID Categorie</b>
</td>
<td>
<b>Nom Categorie</b>
</td>
<td>
<b>Description</b>
</td>
<td>
</td>
</tr>
<?php
while ($ligne=mysql_fetch_row($result))
{
$idcateg=$ligne[0];
$nomcateg=$ligne[1];
$descriptioncateg=$ligne[2];
?>
<form name="supcateg" action="produit.php" method="POST">
<tr align='center'>
<td>
<?php print $idcateg?>
</td>
<td>
<a href="modifcateg.php?loguer=oui&idcateg=<?php print $idcateg?>&<?php print session_name()?>=<?php print session_id()?>"><?php print $nomcateg?></a>
</td>
<td>
<input type="hidden" name="supcat" value="go"/>
<input type="hidden" name="desc" value="<?php print $descriptioncateg?>"/>
<input type="hidden" name="idcateg" value="<?php print $idcateg?>"/>
<input type="hidden" name="loguer" value="oui"/>
<?php print $descriptioncateg?>
</td>
<td>
<input type="submit" value="supprimer"/>
</td>
</tr>
</form>
<?php
}
} else {
print "<tr><td colspan=4><a href=\"login.php\">Une erreure s'est produite veuillez vous reconnecter</a></td></tr>";
session_destroy("loguer");
}
?>
</table>
</td>
</tr>
</table>
</div>
<?php
if ($loguer==oui)
{
?>
<a href="index.php?loguer=oui&<?php print session_name();?>=<?php print session_id();?>">Retour</a>
<?php
} else {
?>
<a href="index.php?<?php print session_name();?>=<?php print session_id();?>">Retour</a>
<?php
}
?>
<?php
}
else
{
print "Erreur de connection";
}
?>
</body>
</html>