- Home
- Categorie
- Coding e Sistemistica
- Coding
- come si implementa un antispam in un formulario?
-
come si implementa un antispam in un formulario?
ciao a tutti, sto cercando di inserire in un formulario un sistema antispam, tipo una serie alfanumerica da inserire in un campo apposito che validi e invii il formulario
qualcuno mi saprebbe aiutare?
grazie mille e ciao
-
visto che nessuno mi risponde (forse non sono stato chiaro nella domanda) mi sono mosso per conto mio e ho aggiunto un generatore di immagini numeriche e l'ho aggiunto ad un formulario
lo potete trovare qui: http://www.abello-abogados.com/formulari/cas-div-mail.php
il formulario controlla se il numero introdotto nel campo a lato è corretto e quindi procede all'invio o restituisce un messaggio d'errore
il problema è che, a volte si e a volte no, al posto dell'immagine appare la classica casellina con la croce sinonimo di errore
non riesco a capire se è un problema di gestione della sessione oppure se è il server che fa le bizze
questo è il codice:
<? session_start(); $code3 = $_SESSION['code']; include('ic_mod.php'); $id = getmagicid(); $imf = crypt($id[1] , $scode ); require("cas-div-conf.php"); ?> <html> <head> <title><? echo $title ?></title> <link rel="stylesheet" type="text/css" href="form-estilo.css"> </head> <body> <table align="center" width="580" border=0 cellspacing=0 cellpadding=1> <tr><td class="MainTD"> <table width="100%" border=0 cellspacing=0 cellpadding=3> <tr> <td class="HeaderText"><? echo $maintxt ?></td> <tr> <td class="NormalText"> <? if ($send == "ok") { if ($correo == "") { $ok = "false"; $erb = "<font class=\"Error\"> $nomail</font>\n"; } if ($correo != "") { if (!eregi( "^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $correo)) { $erb = "<font class=\"Error\"> $wrongmail</font>\n"; $ok = "false"; } } if ($comentarios == ""){ $ok= "false"; $erc = "<font class=\"Error\"> $nomessage</font>\n"; } if ($code3 != $_POST['code']) { $ok= "false"; $erd = "<font class=\"Error\"> $nocodigo</font>\n"; } if ($ok != "false"){ mail("$email", "$oggetto","$comentarios\n\n---------\nCame correo host: $REMOTE_HOST\nIP Adress: $REMOTE_ADDR", "correo:<$correo>\nReply-To:<$correo>\nSender:<$correo>"); echo "$mess1\n"; echo " $thankz\n"; } elseif ($ok == "false") { ?> <form method="POST" action="<? echo $PHP_SELF ?>"> <? echo $emailadress.": ".$erb ?> <input type="text" name="correo" size="30" value="<? echo $correo ?>" maxlength="30"> <? echo $saywhat.": ".$erc ?> <textarea rows="10" name="comentarios" cols="50"><? echo $comentarios ?></textarea> <? echo $antispam.": ".$erd ?> <? echo ' <input id="code" name="code" /> <input id="code2" name="code2" type="hidden" value="', $id[0] ,'" /> <input type="hidden" name="send" value="ok"> <input type="submit" value="Enviar"> <input type="reset" value="Borrar"> </form>'; ?> <? } } else { ?> <form method="POST" action="<? echo $PHP_SELF ?>"> <? echo $emailadress ?>: <input type="text" name="correo" size="27"> <? echo $saywhat ?>: <textarea rows="10" name="comentarios" cols="40"></textarea> <? echo $antispam ?> <? echo ' <input id="code" name="code" /> <input id="code2" name="code2" type="hidden" value="', $id[0] ,'" /> <input type="hidden" name="send" value="ok"> <input type="submit" value="Enviar"> <input type="reset" value="Borrar"> </form> '; } ?> </td></tr></table></td></tr></table> <p align="center">[url="index.htm"]Volver a Inicio</p> </body> </html>
cosa vi sembra? qualcuno ha una opinione in merito?
grazie e ciao a tutti