Précédent   Forum des professionnels en informatique > PHP > Langage > Sessions
Sessions Forum d'entraide sur les sessions avec PHP. Avant de poster -> FAQ sessions, Cours sessions et Sources sécurité
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 25/12/2006, 18h09   #1
Invité de passage
 
Inscription : août 2004
Messages : 3
Détails du profil
Informations forums :
Inscription : août 2004
Messages : 3
Points : 1
Points : 1
Envoyer un message via MSN à PicVert
Par défaut [Cookies] Obligation de double cliquer sur "Submit"

Bonjour, et Joyeux noel.

J'aimerais faire un login simple pour mon site web, tout fonctionne très bien mais quand je me log (en local pas tester online). Je dois cliquer une fois sur login (je penses qui'il lit le code) puis recliquer pour afficher la page de résultat. J'aimerais savoir si quelqu'un peut me dire pourquoi je dois cliquer deux fois.. si c'est un bug ou si c'est a cause de localhost... ?

Merci d'avance pour l'aide je voudrais pouvoir publier mon site avant noel prochain HO HO HO joyeux noel encore.

dans mon index.php j'ai la mise en page avec des pseudo-frames dont : longin.php avec le formulaire de login quand l'autentification est réeussie la pseudo-frame deviens loged.php le code :


login.php
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
 
 
<?php
unset($error);
$error='';
?>
<table width="271" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form action="" method="post" name="loginform" id="loginform">
<table width="271" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="32" rowspan="5" align="center" background="images/menu_left.jpg">&nbsp;</td>
<td class="menu" bgcolor="#C0CBAD">Nickname :<br />
<?php
$nickname=$_POST['nickname'];
$password=$_POST['password'];
$seeknicksql="SELECT * FROM members WHERE nickname='$nickname' AND password=SHA1('$password')";
$queryseeknick=mysql_query($seeknicksql);
$numresseeknick=mysql_num_rows($queryseeknick);
$resultseeknick=mysql_fetch_assoc($queryseeknick);
if (($numresseeknick) > 0)
{
	if ($resultseeknick['valid'] > 0)
	{
		$lastconnection=date("Y-m-d");
		$updconsql="UPDATE members SET lastcon='$lastconnection' WHERE nickname='$nickname'";
		mysql_query($updconsql);
		if (($_POST['rememberme'])=="yes")
		{
			$expiration=3600*24*365;
			setcookie("nickname", $nickmembership, time()+$expiration);
			setcookie("loged", "yes", time()+$expiration);
			setcookie("lastcon", $lastconnection, time()+$expiration);
		}
		else
		{
			$expiration=3600*24*1;
			setcookie("nickname", $nickmembership, time()+$expiration);
			setcookie("loged", "yes", time()+$expiration);
			setcookie("lastcon", $lastconnection, time()+$expiration);
		}
	}
	else{}
}
else{}
?>
  <input type="text" name="nickname"></td>
<td width="30" rowspan="5" align="center" background="images/menu_right.jpg">&nbsp;</td>
</tr>
<tr>
<td align="left" class="menu" bgcolor="#C0CBAD">Password :<br /> 
  <input type="password" name="password"></td>
</tr>
<tr>
  <td align="left" class="menu" bgcolor="#C0CBAD">Remember me : 
    <input type="checkbox" name="remeberme" value="yes" /></td>
</tr>
<tr>
  <td align="left" class="menu" bgcolor="#C0CBAD">&nbsp;</td>
</tr>
<tr>
<td align="center" bgcolor="#C0CBAD" class="menu"><span class="menu"><a href="index.php?link=20">
  <input type="reset" name="reset" value="Reset" />
  <input type="submit" name="Submit" value="Submit">
</a></span></td>
</tr>
<tr>
<td height="9" colspan="3" align="left" background="images/menu_end.jpg" class="linesize">.</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
loged.php
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
 
      <table width="271" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="32" rowspan="3" align="center" background="images/menu_left.jpg">&nbsp;</td>
          <td width="30" class="menu" bgcolor="#C0CBAD">Welcome :<?php echo $_COOKIE['nickname'];?></td>
          <td width="30" rowspan="3" align="center" background="images/menu_right.jpg">&nbsp;</td>
        </tr>
        <tr>
          <td align="left" class="menu" bgcolor="#C0CBAD">Last connection : <?php echo $_COOKIE['lastcon'];?></td>
        </tr>
        <tr>
          <td align="right" class="menu" bgcolor="#C0CBAD"><span class="menu"><a href="index.php?link=20">Logout.</a></span></td>
        </tr>
        <tr>
          <td height="9" colspan="3" align="left" background="images/menu_end.jpg" class="linesize">.</td>
          </tr>
      </table>
enfin dans index.php ce code qui defini quelle page afficher :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
 
 
	<?php
	if (($_COOKIE['loged'])=="yes")
	{
		include ("incsys/loged.php");
	}
	else
	{
		include ("incsys/login.php");
	}
	?>
PicVert est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/12/2006, 09h42   #2
Membre régulier
 
Inscription : mai 2005
Messages : 120
Détails du profil
Informations personnelles :
Âge : 27

Informations forums :
Inscription : mai 2005
Messages : 120
Points : 98
Points : 98
Bonjour,

c'est normale car après l'envoie de ton cookie, tu reste sur l'affichage de ton formulaire:
met ton code php de traitement avant ton code html.
comme ceci :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 
<?php
unset($error);
$error='';
 
//Vérifie que le formulaire a été envoyé
if (isset($_POST["submit"])) {
	$nickname=$_POST['nickname'];
	$password=$_POST['password'];
	$seeknicksql="SELECT * FROM members WHERE nickname='$nickname' AND password=SHA1('$password')";
	$queryseeknick=mysql_query($seeknicksql);
	$numresseeknick=mysql_num_rows($queryseeknick);
	$resultseeknick=mysql_fetch_assoc($queryseeknick);
 
	if (($numresseeknick) > 0)
	{
		if ($resultseeknick['valid'] > 0)
		{
			$lastconnection=date("Y-m-d");
			$updconsql="UPDATE members SET lastcon='$lastconnection' WHERE nickname='$nickname'";
			mysql_query($updconsql);
			if (($_POST['rememberme'])=="yes")
			{
				$expiration=3600*24*365;
				setcookie("nickname", $nickmembership, time()+$expiration);
				setcookie("loged", "yes", time()+$expiration);
				setcookie("lastcon", $lastconnection, time()+$expiration);
			}
			else
			{
				$expiration=3600*24*1;
				setcookie("nickname", $nickmembership, time()+$expiration);
				setcookie("loged", "yes", time()+$expiration);
				setcookie("lastcon", $lastconnection, time()+$expiration);
			}
 
			//on redirige vers index.php
			header ("location: index.php");
		}
	}
}
?>
<table width="271" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form action="" method="post" name="loginform" id="loginform">
<table width="271" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="32" rowspan="5" align="center" background="images/menu_left.jpg">&nbsp;</td>
<td class="menu" bgcolor="#C0CBAD">Nickname :<br />
  <input type="text" name="nickname"></td>
<td width="30" rowspan="5" align="center" background="images/menu_right.jpg">&nbsp;</td>
</tr>
<tr>
<td align="left" class="menu" bgcolor="#C0CBAD">Password :<br /> 
  <input type="password" name="password"></td>
</tr>
<tr>
  <td align="left" class="menu" bgcolor="#C0CBAD">Remember me : 
    <input type="checkbox" name="remeberme" value="yes" /></td>
</tr>
<tr>
  <td align="left" class="menu" bgcolor="#C0CBAD">&nbsp;</td>
</tr>
<tr>
<td align="center" bgcolor="#C0CBAD" class="menu"><span class="menu"><a href="index.php?link=20">
  <input type="reset" name="reset" value="Reset" />
  <input type="submit" name="Submit" value="Submit">
</a></span></td>
</tr>
<tr>
<td height="9" colspan="3" align="left" background="images/menu_end.jpg" class="linesize">.</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
il te reste à effectuer les controles sur tes variables nickname et password.
Ouark est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/12/2006, 18h30   #3
Invité de passage
 
Inscription : août 2004
Messages : 3
Détails du profil
Informations forums :
Inscription : août 2004
Messages : 3
Points : 1
Points : 1
Envoyer un message via MSN à PicVert
Merci sa foncitonne maintenant.

PicVert est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 00h08.


 
 
 
 
Partenaires

Hébergement Web