Bonjour, je suis débutant en php
j'ai un probleme de session pour poster mes données via un formulaire
Si quelqu'un peut m'aider SVP!
je vous donne ainsi le code:
Voici le le fichier pproposition1.php
et le fichier pproposition2.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php session_start(); //print("!...".session_id()."....\n"); srand(); $_SESSION["nb_mystere"]=rand(1,100); $_SESSION["essai"]=0; $_SESSION["nom"]=" "; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>jeu du Nombre Mystére</title> </head> <body> <form action="pproposition2.php" method="post"> <p>Votre nom:<input type="text" name="nom" value="" /><br /> <p>Votre premiere proposition <br>(Comprise entre 1 et 100); <br><br /><input type="text" name="proposition" /><br /><br /><br /> <input type="submit" value="proposer" /></p> </form> </body> </html>
Et voila les erreurs que j'ai.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php session_start(); //print("<...".session_id()."....\n"); $_SESSION["essai"]++; if(isset($_POST["nom"])) $_SESSION["nom"]=$_POST["nom"] ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Jeu du Nombre Mystere</title> </head> <body> <?php if($_POST["proposition"]==$_SESSION["nb_mystere"]) { print("<p>Incroyable $_SESSION["nom"] !!!!\n"); print("<br>Vous avez trouvé: </p>\n"); print("<p>le nombre mystere etait en effet $_POST[proposition]!</p>\n"); print("<p> Revenez sur la <a href=\"iindex.php\"> page d'acceuil</a></p>\n"); } else { print("<p>Vous n'avez pas encore trouvé:\n"); print("<br>le nombre $_POST[proposition] proposé est trop"); if($_POST["proposition"]<$_SESSION["nb_mystere"]) print(" petit!</p>\n"); else print(" grand!</p>\n"); ?> <form action="pproposition2.php" method="post"> <?php print("<p>Vous avez déja fait :"); print("<input readonly type=\"text\" name=\"essai\" value=\"$_SESSION[essai]\">essai(s)<br><br><br>\n"); ?> <p>Votre nouvelle proposition <br>(Comprise entre 1 et 100):<br><br> <input type="text" name="proposition" ><br><br />/><br /> <input type="submit" value="proposer"></p> </form> <?php } ?> </body> </html>
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\program files\easyphp1-8\www\nouveau dossier\pproposition1.php:2) in c:\program files\easyphp1-8\www\nouveau dossier\pproposition1.php on line 3
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\program files\easyphp1-8\www\nouveau dossier\pproposition1.php:2) in c:\program files\easyphp1-8\www\nouveau dossier\pproposition1.php on line 3
Merci d'avance!!!







Répondre avec citation
Partager