Bonjour à tous je suis en train de faire un site de jeux (élevage d'animaux virtuels) et dans la partie administration je trouve une erreur que je n'arrive pas à solutionner.
J'espère que vous allez pouvoir m'aider car j'ai beau chercher je n'est pas réussi à me sortir de la mouise ^^
<?php
include('templates.php');
include('config.php');
// Infos du joueur
$id_membres = $_COOKIE['elvme'];
$selection_membres = mysql_query("SELECT * FROM mcroc_membres WHERE id='$id_membres' LIMIT 1");
$mcroc_membres = mysql_fetch_array($selection_membres);
// Infos du joueur
if($id_membres == false) { ?><script language="Javascript">
<!--
document.location.replace("index.php");
// -->
</script>
<? }
if($mcroc_membres['admin'] != "2") { ?>
<script language="Javascript">
<!--
document.location.replace("jeu.php");
// -->
<? }
// Pincipal
if (isset($_GET["page"])) {
$do = explode(":",$_GET["page"]);
if($do[0] == "liste_news") { liste_news(); }
elseif($do[0] == "liste_membres") { liste_membres(); }
elseif($do[0] == "principal") { principal(); }
} else { donothing(); }
function donothing() {
global $haut, $bas;
echo $haut;
// Contenu
echo '<center><div class="hautcadre" align="center"><div class="hauttxt"><b>Menu d\'administration</b> <i>Monsieur le webmaster... :)</i></b></div></div><div class="corpscadre"><div class="contenutxt" align="center"><a href="admin.php?page=liste_news" class="listenews"></a><br><br /><a href="admin.php?page=liste_membres" class="listemembres"></a><br><br /><a href="admin.php?page=principal" class="configuration"></a><br></div></div><div class="bascadre"></div></center>';
// Contenu
echo $bas;
}
function liste_news() {
global $haut, $bas, $mcroc_membres;
echo $haut;
// Contenu
$select_news = mysql_query("SELECT * FROM mcroc_news ORDER BY id DESC");
echo '<center><div class="hautcadre" align="center"><div class="hauttxt"><b>Liste des news</b> <i>Comme dans un journal ;)</i></b></div></div><div class="corpscadre2"><div class="contenutxt" align="center"><center>
<table width="500" border="0" cellpadding="0" cellspacing="0" bgcolor="#91dc78" >
<tr>
<td width="100" align="center"><b>Id</b></td>
<td width="180" align="center"><b>Titre</b></td>
<td width="200" align="center"><b>Lire/Suppr</b></td>
</tr>
</table></center>
<table width="500" bgcolor="#9fe786" align="center" >';
while($news = mysql_fetch_array($select_news))
{
echo '<form action="" method="POST">
<input type="hidden" name="id" value="'.$news['id'].'">
<tr>
<td width="100" align="center">'.$news['id'].'</td>
<td width="180" align="center">'.$news['titre'].'</td>
<td width="200" align="center"><input type="image" src="images/boutons/voir.png" width="140" height="30" name="view" value="Voir">
<input type="image" name="delete" src="images/suppr.png"></td>
</tr>
</form>';
}
echo '</table>
<form action="" method="POST">
<br /><input type="image" src="images/boutons/nouveau.png" width="140" height="30" name="nouveau" value="Nouvelle news">
</form></div></div><div class="bascadre"></div></center>';
if(isset($_POST['view']))
{
extract($_POST);
$select = mysql_query("SELECT * FROM mcroc_news WHERE id='$id' LIMIT 1");
$view = mysql_fetch_array($select);
echo '<br /><center><div class="hautcadre" align="center"><div class="hauttxt"><b>Voir une news</b> <i>Petit curieux...</i></b></div></div><div class="corpscadre2"><div class="contenutxt" align="center"><br><center><table width="359" cellpadding="0" cellspacing="0">
<tr>
<td width="359" height="1" align="center" ><b>'.$view['titre'].'</b></font></td>
</tr>
</table>
<table width="359" cellpadding="0" cellspacing="0">
<tr>
<td width="359" height="1" align="center"><br />'.$view['content'].'<br /><br /></td>
</tr>
</table></center>
<form action="" method="POST">
<input type="hidden" name="id" value="'.$view['id'].'">
<br /><input type="image" src="images/boutons/editer.png" width="140" height="30" name="edit" value="Editer">
</form></div></div><div class="bascadre"></div></center>';
}
if(isset($_POST['edit']))
{
extract($_POST);
$select_news = mysql_query("SELECT * FROM mcroc_news WHERE id='$id' LIMIT 1");
$news = mysql_fetch_array($select_news);
if(isset($_POST['envoye_edit']))
{
extract($_POST);
mysql_query("UPDATE mcroc_news SET titre='$titre', content='$content' WHERE id='$id'");
echo '<script>window.top.location.href="admin.php?page=liste_news";</script>';
}
else
{
echo '
<br /><center><div class="hautcadre" align="center"><div class="hauttxt"><b>Editer une news</b> <i>=D</i></b></div></div><div class="corpscadre2"><div class="contenutxt" align="center"><form action="" method="POST">
<center>
<table width="359" cellpadding="0" cellspacing="0">
<tr>
<td><br />Titre:</td>
<td><br /><input type="text" class="log" name="titre" value="'.$news['titre'].'"></td>
</tr>
<tr>
<td>Texte:</td>
<td><textarea name="content" class="log" cols="30" rows="4" tabindex="80">'.$news['content'].'</textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="hidden" name="id" value="'.$news['id'].'"><input type="hidden" name="edit"><br /><input type="image" src="images/boutons/editer.png" width="140" height="30" name="envoye_edit" value="Editer"><br /><br /></td>
</tr>
</table></center>
</form></div></div><div class="bascadre"></div></center>';
}
}
if(isset($_POST['nouveau']))
{
if(isset($_POST['envoye_nouveau']))
{
extract($_POST);
$date = date("d/m/Y");
mysql_query("INSERT INTO mcroc_news SET id='', titre='$titre', content='$content', pseudo='".$mcroc_membres['nom']."', date='$date'");
echo '<script>window.top.location.href="admin.php?page=liste_news";</script>';
}
else
{
echo '
<br /><center><div class="hautcadre" align="center"><div class="hauttxt"><b>Ecrire une news</b> <i>Sa feed sec.</i></b></div></div><div class="corpscadre2"><div class="contenutxt" align="center"><form action="" method="POST">
<center>
<table width="359" cellpadding="0" cellspacing="0">
<tr>
<td><br />Titre:</td>
<td><br /><input type="text" class="log" name="titre"></td>
</tr>
<tr>
<td>Pseudo:</td>
<td>'.$mcroc_membres['nom'].'</td>
</tr>
<tr>
<td>Message:</td>
<td><textarea name="content" class="log" cols="30" rows="4" tabindex="80"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="hidden" name="nouveau"><br /><input type="image" src="images/boutons/envoyer.png" width="140" height="30" name="envoye_nouveau" value="Envoyer"><br /><br /></td>
</tr>
</table></center>
</form></div></div><div class="bascadre"></div></center>';
}
}
if(isset($_POST['delete_x']))
{
extract($_POST);
mysql_query("DELETE FROM mcroc_news WHERE id='$id'");
echo '<script>window.top.location.href="admin.php?page=liste_news";</script>';
}
// Contenu
echo $bas;
}
function liste_membres() {
global $haut, $bas, $mcroc_membres;
echo $haut;
// Contenu
$selection_membres = mysql_query("SELECT * FROM mcroc_membres ORDER BY id ASC");
echo '<center><div class="hautcadre" align="center"><div class="hauttxt"><b>Liste des membres</b> <i>Qui joue au jeu ?</i></b></div></div><div class="corpscadre2"><div class="contenutxt" align="center"><center>
<table witdth="500" bgcolor="#91dc78" cellpadding="0" cellspacing="0">
<tr>
<td width="100" align="center"><b>Id</b></font></td>
<td width="200" align="center"><b>Nom</b></font></td>
<td width="200" align="center"><b>Voir/Supprimer</b></font></td>
</tr>
</table></center>
<center><table width="500" bgcolor="#9fe786" align="center" >';
while($membres = mysql_fetch_array($selection_membres))
{
echo '<form action="" method="POST">
<input type="hidden" name="id" value="'.$membres['id'].'">
<tr>
<td width="100" align="center">'.$membres['id'].'</td>
<td width="200" align="center">'.$membres['nom'].'</td>
<td width="200" align="center"><input type="image" name="view" src="images/boutons/voir.png" width="140" height="30" value="Voir">
<input type="image" name="delete" src="images/suppr.png"></td>
</tr>
</form>';
}
echo '</table></center></div></div><div class="bascadre"></div></center>';
if(isset($_POST['view']))
{
extract($_POST);
$selection_membres = mysql_query("SELECT * FROM mcroc_membres WHERE id='$id' LIMIT 1");
$membres = mysql_fetch_array($selection_membres);
if(isset($_POST['envoye_edit']))
{
extract($_POST);
mysql_query("UPDATE mcroc_membres SET admin='$admin', email='$email', argent='$argent', avatar='$avatar', nom='$nom', sexe='$sexe', jours='$jours', manger='$manger', boire='$boire', nettoyer='$nettoyer', jouer='$jouer', chasser='$chasser', dormir='$dormir', promener='$promener', soigner='$soigner' WHERE id='$id'");
echo '<script>window.top.location.href="admin.php?page=liste_membres";</script>';
}
else
{
echo '<br />
<center><div class="hautcadre" align="center"><div class="hauttxt"><b>Editer un joueur</b> <i>Rappel : Pas de triche</i></b></div></div><div class="corpscadre2"><div class="contenutxt" align="center"><form action="" method="POST">
<center>
<table width="327" cellpadding="0" cellspacing="0" >
<tr>
<td><br />Login:</td>
<td><br />'.$membres['login'].'</td>
</tr>
<tr>
<td>Password:</td>
<td>'.$membres['password'].'</td>
</tr>
<tr>
<td>Admin:</td>
<td><input type="text" class="log" name="admin" value="'.$membres['admin'].'"><br>1: Joueur / 2: Admin</td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" class="log" name="email" value="'.$membres['email'].'"></td>
</tr>
<tr>
<td>Argent:</td>
<td><input type="text" class="log" name="argent" value="'.$membres['argent'].'"></td>
</tr>
<tr>
<td>Avatar:</td>
<td><input type="text" class="log" name="avatar" value="'.$membres['avatar'].'"></td>
</tr>
<tr>
<td>Nom:</td>
<td><input type="text" class="log" name="nom" value="'.$membres['nom'].'"></td>
</tr>
<tr>
<td>Sexe:</td>
<td><input type="text" class="log" name="sexe" value="'.$membres['sexe'].'"></td>
</tr>
<tr>
<td>Âge:</td>
<td><input type="text" class="log" name="age" value="'.$membres['age'].'"></td>
</tr>
<tr>
<td>Pays:</td>
<td><input type="text" class="log" name="pays" value="'.$membres['pays'].'"></td>
</tr>
<tr>
<td>Jours:</td>
<td><input type="text" class="log" name="jours" value="'.$membres['jours'].'"></td>
</tr>
<tr>
<td>Manger:</td>
<td><input type="text" class="log" name="manger" value="'.$membres['manger'].'"></td>
</tr>
<tr>
<td>Boire:</td>
<td><input type="text" class="log" name="boire" value="'.$membres['boire'].'"></td>
</tr>
<tr>
<td>Nettoyer:</td>
<td><input type="text" class="log" name="nettoyer" value="'.$membres['nettoyer'].'"></td>
</tr>
<tr>
<td>Jouer:</td>
<td><input type="text" class="log" name="jouer" value="'.$membres['jouer'].'"></td>
</tr>
<tr>
<td>Chasser:</td>
<td><input type="text" class="log" name="chasser" value="'.$membres['chasser'].'"></td>
</tr>
<tr>
<td>Dormir:</td>
<td><input type="text" class="log" name="dormir" value="'.$membres['dormir'].'"></td>
</tr>
<tr>
<td>Promener:</td>
<td><input type="text" class="log" name="promener" value="'.$membres['promener'].'"></td>
</tr>
<tr>
<td>Soigner:</td>
<td><input type="text" class="log" name="soigner" value="'.$membres['soigner'].'"></td>
</tr>
<tr>
<td>Allopass:</td>
<td>'.$membres['allopass'].'</td>
</tr>
<tr>
<td>Points:</td>
<td>'.$membres['points'].'</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="hidden" name="id" value="'.$membres['id'].'"><input type="hidden" name="view"><br /><input type="image" src="images/boutons/editer.png" width="140" height="30" name="envoye_edit" value="Editer"><br /><br /></td>
</tr>
</table></center>
</form></div></div><div class="bascadre"></div></center>';
}
}
if(isset($_POST['delete_x']))
{
extract($_POST);
mysql_query("DELETE FROM mcroc_membres WHERE id='$id'");
echo '<script>window.top.location.href="admin.php?page=liste_membres";</script>';
}
// Contenu
echo $bas;
}
function principal() {
global $haut, $bas, $mcroc_membres;
echo $haut;
// Contenu
$selection_configuration = mysql_query("SELECT * FROM mcroc_configuration ORDER BY id ASC");
echo '<center><div class="hautcadre" align="center"><div class="hauttxt"><b>Configuration du jeu</b> <i>Sortez les outils</i></b></div></div><div class="corpscadre2"><div class="contenutxt" align="center"><center>
<table width="500" border="0" bgcolor="#91dc78" cellpadding="0" cellspacing="0" >
<tr>
<td width="100" align="center"><b>Id</font></b></td>
<td width="200" align="center"><b>Nom</font></b></td>
<td width="200" align="center"><b>Actions</b></font></td>
</tr>
</table></center>
<table width="500" bgcolor="#9fe786" align="center" >';
while($configuration = mysql_fetch_array($selection_configuration))
{
echo '<form action="" method="POST">
<input type="hidden" name="id" value="'.$configuration['id'].'">
<tr>
<td width="100" align="center">'.$configuration['id'].'</td>
<td width="200" align="center">'.$configuration['site_nom'].'</td>
<td width="200" align="center"><input type="image" src="images/boutons/voir.png" width="140" height="30" name="view" value="Voir"></td>
</tr>
</form>';
}
echo '</table></div></div><div class="bascadre"></div></center>';
if(isset($_POST['view']))
{
extract($_POST);
$selection_configuration = mysql_query("SELECT * FROM mcroc_configuration WHERE id='$id' LIMIT 1");
$configuration = mysql_fetch_array($selection_configuration);
if(isset($_POST['envoye_edit']))
{
extract($_POST);
mysql_query("UPDATE mcroc_configuration SET site_nom='$site_nom', bete='$bete', monnaie='$monnaie' WHERE id='$id'");
echo '<script>window.top.location.href="admin.php?page=principal";</script>';
}
else
{
echo '
<br />
<center><div class="hautcadre" align="center"><div class="hauttxt"><b>Edition de la configuration</b> <i>:D</i></b></div></div><div class="corpscadre2"><div class="contenutxt" align="center"><form action="" method="POST">
<center>
<table width="359" >
<tr>
<td><br />Site nom:</td>
<td><br /><input type="text" class="log" name="site_nom" value="'.$configuration['site_nom'].'"></td>
</tr>
<tr>
<td>Bête:</td>
<td><input type="text" class="log" name="bete" value="'.$configuration['bete'].'"></td>
</tr>
<tr>
<td>Monnaie:</td>
<td><input type="text" class="log" name="monnaie" value="'.$configuration['monnaie'].'"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="hidden" name="id" value="'.$configuration['id'].'"><input type="hidden" name="view"><br /><input type="image" src="images/boutons/editer.png" width="140" height="30" name="envoye_edit" value="Editer"><br /><br />
</td>
</tr>
</table></center>
</form></div></div><div class="bascadre"></div></center>';
}
}
// Contenu
}
echo $bas;
?>