Bonjour.
Mon captcha n'est jamais synchronisé. Quelque chose m'échappe.
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 session_start(); $couleur = array("yellow","green","blue","red","gray","pink","black"); unset($_SESSION['color']); $color = $couleur[rand(0,5)]; if($color == "yellow") $code = "jaune"; if($color == "green") $code = "vert"; if($color == "blue") $code = "bleu"; if($color == "red") $code = "rouge"; if($color == "gray") $code = "gris"; if($color == "pink") $code = "rose"; if($color == "black") $code = "noir"; $captcha = '<div style="width:20px;"><div style="float:right;width:20px;height:20px;background-color:'.$color.'"></div></div>'; $_SESSION['color'] = $code; if(isset($_POST['color'])) echo '<pre>'; var_dump($_POST['color']); var_dump($_SESSION['color']); if(empty($_POST['color'])) if($_POST['color'] == $_SESSION['color']){ echo 'ok'; unset($_SESSION['color']); } ?> <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST"> <input type="hidden" name="token" value="<?php echo $token; ?>" /> <input style="width:66px" type="submit" name="envoye" value="Envoyer" /> <input style="width:66px" type="reset" name="annuler" value="Annuler" /> Quelle est cette couleur? <?php echo $captcha; ?> <input class="form" style="width:75px" type="text" id="color" name="color" value="" size="10" /> </form> </pre>
Partager