Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
PHP - aggiungere captcha
Forum - PHP - aggiungere captcha

Avatar
Il_maca (Ex-Member)
Pro


Messaggi: 163
Iscritto: 28/01/2009

Segnala al moderatore
Postato alle 12:49
Venerdė, 11/09/2009
salva raga, premetto che di php non conosco molto, ma ne ho bisogno per un sito che sto facendo con degli amici! quindi:
io ho:
il file php del captcha:

Codice sorgente - presumibilmente Php

  1. <?php
  2.  
  3. /**
  4.  * Project:     Securimage: A PHP class for creating and managing form CAPTCHA images<br />
  5.  * File:        form.php<br /><br />
  6.  *
  7.  * This is a very simple form sending a username and password.<br />
  8.  * It demonstrates how you can integrate the image script into your code.<br />
  9.  * By creating a new instance of the class and passing the user entered code as the only parameter, you can then immediately call $obj->checkCode() which will return true if the code is correct, or false otherwise.<br />
  10.  *
  11.  * This library is free software; you can redistribute it and/or
  12.  * modify it under the terms of the GNU Lesser General Public
  13.  * License as published by the Free Software Foundation; either
  14.  * version 2.1 of the License, or any later version.<br /><br />
  15.  *
  16.  * This library is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19.  * Lesser General Public License for more details.<br /><br />
  20.  *
  21.  * You should have received a copy of the GNU Lesser General Public
  22.  * License along with this library; if not, write to the Free Software
  23.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA<br /><br />
  24.  *
  25.  * Any modifications to the library should be indicated clearly in the source code
  26.  * to inform users that the changes are not a part of the original software.<br /><br />
  27.  *
  28.  * If you found this script useful, please take a quick moment to rate it.<br />
  29.  * http://www.hotscripts.com/rate/49400.html  Thanks.
  30.  *
  31.  * @link http://www.phpcaptcha.org Securimage PHP CAPTCHA
  32.  * @link http://www.phpcaptcha.org/latest.zip Download Latest Version
  33.  * @link http://www.phpcaptcha.org/Securimage_Docs/ Online Documentation
  34.  * @copyright 2007 Drew Phillips
  35.  * @author drew010 <drew@drew-phillips.com>
  36.  * @version 1.0.3.1 (March 23, 2008)
  37.  * @package Securimage
  38.  *
  39.  */
  40. ?>
  41. <html>
  42. <body>
  43.  
  44. <?php
  45. if (empty($_POST)) {?>
  46. <form name="Captcha" method="POST" id="Form1">
  47.  
  48. <div id="bv_Html1" style="position:absolute;left:10px;top:9px;width:150px;height:75px;z-index:2" align="left">
  49. <img src="securimage_show.php?sid=<?php echo md5(uniqid(time())); ?>" id="image" align="absmiddle" />
  50. </div>
  51.  
  52. <div id="bv_Html2" style="position:absolute;left:169px;top:9px;width:30px;height:30px;z-index:0" align="left">
  53. <a href="securimage_play.php" style="font-size: 13px"><img src="images/audio_icon.gif"></a>
  54. </div>
  55.  
  56. <div id="bv_Html3" style="position:absolute;left:169px;top:53px;width:30px;height:30px;z-index:1" align="left">
  57. <a href="#" onclick="document.getElementById('image').src = 'securimage_show.php?sid=' + Math.random(); return false"><img src="images/refresh.png"></a>
  58. </div>
  59.  
  60. <input type="text" id="code" style="position:absolute;left:10px;top:92px;width:70px;font-family:Courier New;font-size:16px;z-index:3" size="7" name="code" value="" maxlength="5">
  61. <input type="submit" id="Button1" name="Button1" value="Conferma" style="position:absolute;left:89px;top:92px;width:72px;height:24px;z-index:4">
  62.  
  63. </form>
  64. <?php
  65. } else { //form is posted
  66.   include("securimage.php");
  67.   $img = new Securimage();
  68.   $valid = $img->check($_POST['code']);
  69.  
  70.   if($valid == true) {
  71.     echo "Thanks, you entered the correct code.</center>";
  72.   } else {
  73.     echo "<center>Sorry, the code you entered was invalid.  <a href=\"javascript:history.go(-1)\">Go back</a> to try again.</center>";
  74.   }
  75. }
  76.  
  77. ?>
  78.  
  79. </body>
  80. </html>



con relativi files che richiama;
e il file della form di registrazione (sempre php):


Codice sorgente - presumibilmente HTML

  1. <?php
  2. session_start();
  3. if ($_SESSION['email_address'] != "" ) {
  4.         echo "<b>Accesso negato! Non hai i permessi per accedere.</b><br><br><br>";
  5.  
  6.  
  7. if ( empty( $first_name ) ) {
  8.         print "Effettua il login a questo link!";
  9.         include 'index.htm';
  10.  
  11. }
  12. } else { print "
  13. <html>
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  16. <title>Untitled Page</title>
  17. <meta name="GENERATOR" content="Created by BlueVoda">
  18. </head>
  19. <body bgcolor="#FFFFFF" text="#000000">
  20. <div id="bv_Form1" style="position:absolute;left:140px;top:129px;width:365px;height:490px;z-index:20" align="left">
  21. <form name="form1" method="POST" action="register.php" enctype="text/plain" id="Form1">
  22. <div id="bv_Text1" style="position:absolute;left:9px;top:30px;width:125px;height:16px;z-index:0" align="left">
  23. <font style="font-size:13px" color="#000000" face="Arial">Nome:</font></div>
  24. <input type="text" id="Editbox1" style="position:absolute;left:145px;top:22px;width:200px;font-family:Courier New;font-size:16px;z-index:1" size="20" name="first_name" value="" maxlength="25">
  25. <div id="bv_Text2" style="position:absolute;left:9px;top:59px;width:125px;height:16px;z-index:2" align="left">
  26. <font style="font-size:13px" color="#000000" face="Arial">Cognome:</font></div>
  27. <input type="text" id="Editbox2" style="position:absolute;left:145px;top:51px;width:200px;font-family:Courier New;font-size:16px;z-index:3" size="20" name="last_name" value="" maxlength="25">
  28. <div id="bv_Text3" style="position:absolute;left:167px;top:82px;width:58px;height:16px;z-index:4" align="left">
  29. <font style="font-size:13px" color="#000000" face="Arial">Maschio</font></div>
  30. <input type="radio" id="RadioButton1"" name="sex" value="M" checked style="position:absolute;left:145px;top:80px;z-index:5">
  31. <div id="bv_Text4" style="position:absolute;left:269px;top:82px;width:59px;height:16px;z-index:6" align="left">
  32. <font style="font-size:13px" color="#000000" face="Arial">Femmina</font></div>
  33. <input type="radio" id="RadioButton2"" name="sex" value="F" style="position:absolute;left:247px;top:80px;z-index:7">
  34. <input type="submit" id="Button1"" name="submit" value="Conferma Iscrizione" style="position:absolute;left:200px;top:445px;width:146px;height:25px;z-index:8">
  35. <div id="bv_Text9" style="position:absolute;left:9px;top:85px;width:125px;height:16px;z-index:9" align="left">
  36. <font style="font-size:13px" color="#000000" face="Arial">Sesso:</font></div>
  37. <input type="text" id="Editbox3" style="position:absolute;left:145px;top:138px;width:200px;font-family:Courier New;font-size:16px;z-index:10" size="20" name="email_address" value="" maxlength="30">
  38. <input type="password" id="Editbox4" onkeyup="runPassword(this.value, 'password');return false;" style="position:absolute;left:145px;top:167px;width:200px;font-family:Courier New;font-size:16px;z-index:11" size="20" name="password" value="" maxlength="25">
  39. <input type="password" id="Editbox5" style="position:absolute;left:145px;top:196px;width:200px;font-family:Courier New;font-size:16px;z-index:12" size="20" name="passwordc" value="" maxlength="25">
  40. <textarea name="info" id="TextArea1" style="position:absolute;left:145px;top:226px;width:200px;height:58px;z-index:13" rows="2" cols="17">


Ultima modifica effettuata da Il_maca il 11/09/2009 alle 12:51
PM Quote
Avatar
Il_maca (Ex-Member)
Pro


Messaggi: 163
Iscritto: 28/01/2009

Segnala al moderatore
Postato alle 12:50
Venerdė, 11/09/2009
Ok risolto!! era una stupidaggine dovuta all'inesperienza col linguaggio!

Ultima modifica effettuata da Il_maca il 14/09/2009 alle 10:28
PM Quote