Bonsoir à tous,
J'ai récupéré une source qui m'intéresse pour essayer de sécuriser mon livre d'or.
Voici le code :
Code html : 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 <!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> <title>BotBoot</title> <script type="text/javascript"> var a = Math.ceil(Math.random() * 10); var b = Math.ceil(Math.random() * 10); var c = a + b function DrawBotBoot() { document.write("What is "+ a + " + " + b +"? "); document.write("<input id='BotBootInput' type='text' maxlength='2' size='2'/>"); } function ValidBotBoot(){ var d = document.getElementById('BotBootInput').value; if (d == c) return true; return false; } </script> </head> <body> Are you human?<br /> <script type="text/javascript">DrawBotBoot()</script> <input id="Button1" type="button" value="Check" onclick="alert(ValidBotBoot());"/> </body> </html>
Cela fonctionne sans problème sauf que voudrais le transformer un peu de façon à n'avoir une alerte que si le résultat est faux en bloquant l'envoi du message dans mon livre d'or et à l'inverse permettre l'envoi du message sans une alerte comme quoi le résultat est bon.
Voici le code de ma page :
Code html : 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta name="description" CONTENT=""> <meta HTTP-EQUIV="IMAGETOOLBAR" content="no" SCROLLING="yes" > <meta name="keywords" CONTENT=""> <head> <title>Livre d'or</title> <script src="jquery.js"></script> <style type="text/css"> body { background: #000000; color: #000000; font-family: Verdana ; color:white; font-size:14px; } </style> <style type="text/css"> div.grande { width : 70%; } p{ line-height:25px; } </style> <?php if(isset($_POST['nobot'])) { // la case est cochée } ?> <script type="text/javascript"> var a = Math.ceil(Math.random() * 10); var b = Math.ceil(Math.random() * 10); var c = a + b function DrawBotBoot() { document.write("What is "+ a + " + " + b +"? "); document.write("<input id='BotBootInput' type='text' maxlength='2' size='2'/>"); } function ValidBotBoot(){ var d = document.getElementById('BotBootInput').value; if (d == c) return true; return false; } </script> </head> <body> <form method=post action=writeguest.php onSubmit='if ( this.nom.value.length < 2 ) { return false ;}' > <BR><p align="center"><FONT FACE="gabriola" size="9" color="white">titre</FONT></BR><FONT FACE="gabriola" size="6" color="white">Livre d'or </FONT></p></FONT> <table border="0" align="center"> <tr><td><img src="test.jpg"></td><td> <Div> <table> <tr><td><FONT FACE="monotype corsiva" size="4" color="white">Nom :</FONT></td> <td><input type=text name=nom size=25 ></td></tr> <tr><td><FONT FACE="monotype corsiva" size="4" color="white">Mail :</FONT></td> <td><input type=text name=mail size=25 ></td></tr> <tr><td><FONT FACE="monotupe corsiva" size="4" color="white">Message:</FONT></td><td colspan=1> <textarea name=message rows=6 cols=47></textarea> </td></tr> </table> </Div> </td><td><img src="livre.jpg"></td></td></tr></table> <!-- On affiche l'image générée par notre script --> <script> $(document).ready(function(){ $('<div style="text-align:center;"><input type="checkbox" name="nobot" required="true"> Je confirme ne pas être un robot</div>').prependTo($('#maDiv')); }); </script> <div style="text-align:center;"><div id="maDiv"></div></div></BR> <div style="text-align:center;"><script type="text/javascript">DrawBotBoot()</script></div> <div style="text-align:center;"><INPUT border=0 src="envoyer.jpg" type=image onclick="alert(ValidBotBoot());" name="sub" value="envoyer" /></div> </form> <div style="text-align:center;"><a href="http://index.php"onMouseOver="window.status='';return true"><img src="bfermer.jpg" BORDER="0" alt=""/></a></div> <div align="center" ><div class="grande" style="border:3px solid #000000; padding 1px;"><div style="text-align:left;"><FONT FACE="gabriola" size="6" color="white" >Vos impressions, commentaires:</FONT></div></div> <div align="center" > <div class="grande" style="border:3px solid #FFFFFF; padding 3px;"><div style="text-align:left;"> <?php include("guestbook.txt"); ?></div></div> </body> </html>
Merci par avance à tous ceux qui pourront m'apporter un peu d'aide car malgré de très nombreux tests je n'y arrive pas !!!
Amicalement scoubi
Partager