Re: Bug étrange avec les formulaires ... [Résolu]
Posté : 17 déc. 2010, 00:13
Bonsoir à tous,
Je viens vous demander de l'aide car j'ai un bug très étrange. Je suis en train de faire un jeu par navigateur (oui oui, je sais c'est très original comme idée...) et j'ai fais une formulaire d'inscription (fonctionne) , la connexion à notre compte avec des variables de sessions (ok) et la je suis en train de réaliser le création d'un personnage depuis le compte crée lorsque l'on est connecté.
Mais, dès que je me connecte, aucun formulaire n'est traité et pire encore mes variables de sessions sont modifiés... En gros je suis connecté au site ($_SESSION['co'] passe à 1 et mon menu pour les membres connectés s'affiche) , et dès que je veux créer un perso via la formulaire, ma page se réactualise et la variable de session 'co' passe à 0 et quelque soit le nom que j'ai mis dans le "action" du formulaire, j'ai tout simplement l'impression que le formulaire n'est pas lu...
Je vous met les liens de mon site pour que vous puissiez tester:
http://magic9110.free.fr/SiteDeDieu/index.php (vous pouvez créer un compte bidon il n'y a pas de test de validité sur les e-mails ou autres pour le moment)
formulaire de création:
Je viens vous demander de l'aide car j'ai un bug très étrange. Je suis en train de faire un jeu par navigateur (oui oui, je sais c'est très original comme idée...) et j'ai fais une formulaire d'inscription (fonctionne) , la connexion à notre compte avec des variables de sessions (ok) et la je suis en train de réaliser le création d'un personnage depuis le compte crée lorsque l'on est connecté.
Mais, dès que je me connecte, aucun formulaire n'est traité et pire encore mes variables de sessions sont modifiés... En gros je suis connecté au site ($_SESSION['co'] passe à 1 et mon menu pour les membres connectés s'affiche) , et dès que je veux créer un perso via la formulaire, ma page se réactualise et la variable de session 'co' passe à 0 et quelque soit le nom que j'ai mis dans le "action" du formulaire, j'ai tout simplement l'impression que le formulaire n'est pas lu...
Je vous met les liens de mon site pour que vous puissiez tester:
http://magic9110.free.fr/SiteDeDieu/index.php (vous pouvez créer un compte bidon il n'y a pas de test de validité sur les e-mails ou autres pour le moment)
formulaire de création:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
</head>
<body>
<table class="normal">
<tr >
<td align="center">
<br/>
<form action="index.php" method="post" enctype="multipart/form-data">
<legend><b>Entrer le nom du perso et choisissez son sexe et sa race.<br/>Le choix de la race aura un impact direct sur ses caractéristiques !<br/><br/></b></legend>
<span>Pseudo du personnage :</span>
<div class="menu_bar"><input class="menu_imput2" type="login" name="perso"/></div><br/>
<span>Sexe :</span>
<select name="choix_sexe">
<option value="Homme">Homme</option>
<option value="Femme">Femme</option>
</select><br/><br/>
<span>Race :</span>
<select name="choix_race">
<option value="Humain">Humain</option>
<option value="Elfe">Elfe</option>
<option value="DarkElfe">Dark Elfe</option>
<option value="Orc">Orc</option>
<option value="Nain">Nain</option>
</select>
<br/><br/>
<input class="menu_submit3" type="submit" value="OK" />
</form>
</td>
</tr>
</table>
</body>
</html>
index.php:
<?php
session_start();
include("nomspages.php");
$link = mysql_connect("sql.free.fr", "******", "******");
mysql_select_db("magic9110");
$retour = mysql_query('SELECT COUNT(*) AS nbre_entrees FROM online WHERE ip=\'' . $_SERVER['REMOTE_ADDR'] . '\'');
$donnees = mysql_fetch_array($retour);
#
#
if ($donnees['nbre_entrees'] == 0) // L'ip ne se trouve pas dans la table, on va l'ajouter
#
{
#
mysql_query('INSERT INTO online (ip, timestamp) VALUES(\'' . $_SERVER['REMOTE_ADDR'] . '\', ' . time() . ')');
#
}
#
else // L'ip se trouve déjà dans la table, on met juste à jour le timestamp
#
{
#
mysql_query('UPDATE online SET timestamp=' . time() . ' WHERE ip=\'' . $_SERVER['REMOTE_ADDR'] . '\'');
#
}
// -------
#
// ETAPE 2 : on supprime toutes les entrées dont le timestamp est plus vieux que 5 minutes
#
#
// On stocke dans une variable le timestamp qu'il était il y a 5 minutes :
#
$timestamp_5min = time() - (60 * 2); // 60 * 2 = nombre de secondes écoulées en 2 minutes
#
mysql_query('DELETE FROM online WHERE timestamp < ' . $timestamp_5min);
#
#
// -------
#
// ETAPE 3 : on compte le nombre d'ip stockées dans la table. C'est le nombre de visiteurs connectés
#
$retour = mysql_query('SELECT COUNT(*) AS nbre_entrees FROM online');
#
$donnees = mysql_fetch_array($retour);
$result = mysql_query("SELECT * FROM table_users");
$i_nbLigne = mysql_num_rows($result);
if ( (isset($_POST['perso'])) && (isset($_POST['choix_race'])) && (isset($_POST['choix_sexe'])) )
{
if ( !(empty($_POST['identifiant'])) && !(empty($_POST['mot_de_passe'])) && !(empty($_POST['e_mail'])) )
{
mysql_query("UPDATE table_users SET perso = '" . $_SESSION['perso'] . "' , race = '" . $_SESSION['choix_race'] . "' , sexe = '" . $_SESSION['choix_sexe'] . "' WHERE pseudo = '" . $_SESSION['pseudo'] ."' ");
if($_POST['choix_race'] == 'Humain')
{
mysql_query('UPDATE table_users SET vie = 100, vie_max = 100, mana = 500, mana_max = 500, cp = 50, cp_max = 50 WHERE pseudo =\'' . $_SESSION['pseudo'] . '\'');
}
if($_POST['choix_race'] == 'Elfe')
{
mysql_query('UPDATE table_users SET vie = 90, vie_max = 90, mana = 600, mana_max = 600, cp = 45, cp_max = 45, adena = 0, ancient_adena = 0, force = 100 WHERE pseudo =\'' . $_SESSION['pseudo'] . '\'');
}
if($_POST['choix_race'] == 'DarkElfe')
{
mysql_query('UPDATE table_users SET vie = 80, vie_max = 80, mana = 600, mana_max = 600, cp = 40, cp_max = 40 WHERE pseudo =\'' . $_SESSION['pseudo'] . '\'');
}
if($_POST['choix_race'] == 'Orc')
{
mysql_query('UPDATE table_users SET vie = 110, vie_max = 110, mana = 400, mana_max = 400, cp = 55, cp_max = 55 WHERE pseudo =\'' . $_SESSION['pseudo'] . '\'');
}
if($_POST['choix_race'] == 'Nain')
{
mysql_query('UPDATE table_users SET vie = 120, vie_max = 120, mana = 300, mana_max = 300, cp = 60, cp_max = 60 WHERE pseudo =\'' . $_SESSION['pseudo'] . '\'');
}
$req = $bdd->exec('UPDATE table_users SET creation = 1 WHERE pseudo =\'' . $_SESSION['pseudo'] . '\'');
$_SESSION['co']=0;
echo "Personnage Créé, veuillez vous reconnecter";
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Lineage ][ Fan Game</title><meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<meta NAME="description" CONTENT="Lineage 2, Gracia epilogue, la2, illicitegames, mmorpg, game, online, serveur">
<meta name="robots" content="index, follow">
<meta HTTP-EQUIV="Content-Language" CONTENT="FR">
<meta HTTP-EQUIV="Content-Language" CONTENT="EN">
<LINK rel="SHORTCUT ICON" href="img/favicon.png">
<link href="css/style.css" type=text/css rel=StyleSheet>
</head>
<body>
<table width="100%" height="100%" align="center" class="normal" valign="top" cellpadding="0" cellspacing="0" border="0">
<tr>
<td height="421" colspan="2" style="background: #b3ffe3 url(img/head1.jpg) no-repeat; background-position: top right;"> </td>
<td height="421" width="510" style="background-image: url(img/head2.jpg); background-repeat: no-repeat; background-position: top center;" nowrap> </td>
<td height="421" colspan="2" style="background: #48a7c0 url(img/head3.jpg) no-repeat; background-position: top left;" align="right" valign="top"><div style="padding: 8px"><a href="../l2top.ru/vote/11315/default.htm" target="_blank"></a></div></td>
</tr>
<tr>
<td height="421" style="background: #b3ffe3 url(img/left2.jpg) no-repeat; background-position: top right;">
<table width="100%" height="100%" align="center" class="normal" valign="top" cellpadding="0" cellspacing="0" border="0">
<tr>
<td height="100%" style="background: url(img/left3.jpg) no-repeat; background-position: bottom right;"> </td>
</tr>
</table>
</td>
<td width="268" style="background: #b3ffe3 url(img/left1.jpg) no-repeat; background-position: top right;" valign="top">
<table width="268" height="100%" align="center" class="normal" valign="top" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top" height="176" style="padding-top: 50px; padding-left: 25px;">
<?php
if ( isset($_SESSION['co'] ))
{
echo " session_co = " ;
echo $_SESSION['co'];
echo "<br/><br/>";
if ($_SESSION['co'] == 1 )
{
include("ol.php");
}
else
{
include("hl.php");
}
}
else
{
include("hl.php");
}
?>
</td>
</tr>
<tr>
<td valign="top" height="160" style="background: #efe3ac url(img/menubg1.jpg) repeat-y; background-position: top right;">
<table width="100%" height="160" align="center" class="normal" valign="top" cellpadding="0" cellspacing="0" border="0" style="background-image: url(img/menubg2.jpg); background-repeat: no-repeat; background-position: bottom right;">
<tr>
<td valign="top" style="padding-left: 13px; padding-bottom: 12px;">
<table width="100%" height="100%" align=center class=normal valign=top cellpadding=0 cellspacing=0 border=0>
<tr>
<td height="24" style="background: url(img/menu1.jpg) no-repeat;"> </td>
</tr>
<tr>
<td height="20" style="background: url(img/menut.jpg) no-repeat;"><a href="index.php" class="mlink"> Accueil </a></td>
</tr>
<tr>
<td height="20" style="background: url(img/menut.jpg) no-repeat;"><a href="index.php?page=histoire" class="mlink"> L'Histoire </a></td>
</tr>
<tr>
<td height="20" style="background: url(img/menut.jpg) no-repeat;"><a href="index.php?page=races" class="mlink"> Les Races </a></td>
</tr>
<tr>
<td height="20" style="background: url(img/menut.jpg) no-repeat;"><a href="index.php?page=formulaire" class="mlink"> Créer un compte </a></td>
</tr>
<tr>
<td height="20" style="background: url(img/menut.jpg) no-repeat;"><a href="" class="mlink"> Comment jouer? </a></td>
</tr>
<tr>
<td height="20" style="background: url(img/menut.jpg) no-repeat;"><a href="index.php?page=contact" class="mlink"> Nous contacter</a></td>
</tr>
<?php
if ( isset($_SESSION['co']))
{
if ($_SESSION['co'] == 1 )
{
echo $test = "<tr><td height=20 style='background: url(img/menut.jpg) no-repeat;'><a href='index.php?page=choix' class='mlink'> Créer un perso </a></td></tr>";
if (isset($_SESSION['existe']))
{
if($_SESSION['existe'] == 1)
{
include("finmenu.php");
}
}
}
}
?>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" style="height: 100%; background: #b3ffe3 url(img/menubg3.jpg) repeat-y; background-position: top right; border:0px solid #F00;"> </td>
</tr>
<tr>
<td height="270" valign="top" style="background-image: url(img/left1b.jpg); background-repeat: no-repeat; background-position: bottom right;"> </td>
</tr>
</table>
<td width="510" style="background: #f7f1e3 url(img/bodytop.jpg) no-repeat; background-position: top; " valign="top" class="normal">
<div style="padding: 10px; padding-top: 12px;"><center></div>
<table width="484" cellpadding="0" cellspacing="0" class="normal" align="center">
<tr>
<td style="background: url(img/div1.png) no-repeat top; padding-left: 100px; padding-right: 250px; padding-top: 6px;" height="37" align="center" class="caption"><?php if ( (isset($_GET['page']))){echo $mesTitres[$_GET['page']];}else{echo ("Presentation");}?></td>
</tr>
<tr>
<td style="background: #ede0ca url(img/div2.jpg) repeat-y top; padding: 16px;" height="37">
<div id="survol1">
<?php
$pageOK = array('inscription'=>'inscription.php','accueil'=>'accueil.php','connexion'=>'connexion.php','formulaire'=>'formulaire.php','choix'=>'choix.php','perso'=>'perso.php','races'=>'races.php','histoire'=>'histoire.php','histoire2'=>'histoire2.php','contact'=>'contact.php','remerciement'=>'remerciement.php','mdp'=>'mdp.php');
if ( (isset($_GET['page'])) && (isset($pageOK[$_GET['page']])) )
{
include($pageOK[$_GET['page']]); // Nous appelons le contenu central de la page
}
else
{
include('pre.php'); // Page par défaut quant elle n'existe pas dans le tableau
}
?>
</div>
</td>
</tr>
<tr>
<td style="background: #ede0ca url(img/div3.jpg) no-repeat top;" height="21"> </td>
</tr>
</table>
<br/>
<br/>
<br/>
<br/>
</td>
<td width="268" style="height:100%; background: #48a7c0 url(img/banerbarlower.jpg) repeat-y; background-position: left; border: lime 0px solid;" valign="top">
<table class="normal" cellpadding="0" cellspacing="0" border="0" style="width:100%; height: 100%; background-image: url(img/banerbarlower.jpg); background-repeat: repeat-y; background-position: top left; border:0px solid #00F;">
<tr>
<td valign="top">
<table width="100%" height="409" align="center" class="normal" valign="top" cellpadding="0" cellspacing="0" border="0" style="background: #1c3a39 url(img/right1b.jpg) no-repeat; background-position: bottom;">
<tr>
<td valign="top" height="203" style="background: #1c3a39 url(img/banerbar1.jpg) no-repeat; background-position: top left; padding-left: 30px; padding-top: 45px;"><!--<a href="vote.php"><img src="img/banner_start.jpg" border="0"></a>--></td>
</tr>
<tr>
<td height="203" valign="top" class="status" style="background: #1c3a39 url(img/banerbar2.jpg) no-repeat; background-position: top left; padding-left: 30px; padding-top: 34px;"><p align="center"><br>
<strong><span class="Style3"><u>STATISTIQUES</u> :</span><br/><br/>
<span>Comptes créés : </span><span class="Style1"><?php echo $i_nbLigne;?></span><br/>
<span>En Ligne : </span><span class="Style1"><?php echo $donnees['nbre_entrees'];?></span><br/></strong>
</td>
</tr>
<tr>
<td valign="top" height="203" style="background: #1c3a39 url(img/banerbar3.jpg) no-repeat; background-position: top left;" class="status">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="height: 100%; border:0px solid #F00;"> </td>
</tr>
<tr>
<td valign="top" style="height: 270px; background: #48a7c0 url(img/right1b.jpg) no-repeat; background-position: left bottom; "> </td>
</tr>
</table>
</td>
<td height="421" style="background: #48a7c0 url(img/right2.jpg) no-repeat; background-position: top left;">
<table width="100%" height="100%" align="center" class="normal" valign="top" cellpadding="0" cellspacing="0" border="0">
<tr>
<td height="100%" style="background: url(img/right3.jpg) no-repeat; background-position: bottom left;"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="274" colspan="2" style="background: #b3ffe3 url(img/foot1.jpg) no-repeat; background-position: top right;"> </td>
<td height="274" width="510" style="background: #48a7c0 url(img/foot2.jpg) no-repeat; background-position: top center;" class="footer"><div style="padding: 50px; padding-left: 250px; "><br><br><br><br>
<br/>
<td height="274" colspan="2" style="background: #48a7c0 url(img/foot3.jpg) no-repeat; background-position: top left;"> </td>
</tr>
</table>
</body>
</html>