• User Attivo

    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


  • User Attivo

    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&#40;&#41;;
     $code3 =  $_SESSION&#91;'code'&#93;;
     include&#40;'ic_mod.php'&#41;;
     $id = getmagicid&#40;&#41;;
     $imf = crypt&#40;$id&#91;1&#93; , $scode &#41;;
    require&#40;"cas-div-conf.php"&#41;;
    ?>
    <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 &#40;$send == "ok"&#41; &#123;
            if &#40;$correo == ""&#41; &#123;
                    $ok = "false";
                    $erb = "<font class=\"Error\"> $nomail</font>\n";
            &#125;
            if &#40;$correo != ""&#41; &#123;
                    if &#40;!eregi&#40; "^&#91;_\.0-9a-z-&#93;+@&#40;&#91;0-9a-z&#93;&#91;0-9a-z-&#93;+\.&#41;+&#91;a-z&#93;&#123;2,3&#125;$", $correo&#41;&#41; &#123;
                            $erb = "<font class=\"Error\"> $wrongmail</font>\n";
                            $ok = "false";
                    &#125;
            &#125;
            if &#40;$comentarios == ""&#41;&#123;
                    $ok= "false";
                    $erc = "<font class=\"Error\"> $nomessage</font>\n";
            &#125;
    		if &#40;$code3 != $_POST&#91;'code'&#93;&#41;
          &#123;
             $ok= "false";
    		 $erd = "<font class=\"Error\"> $nocodigo</font>\n";
          &#125;
            if &#40;$ok != "false"&#41;&#123;
                    mail&#40;"$email", "$oggetto","$comentarios\n\n---------\nCame correo host: $REMOTE_HOST\nIP Adress&#58; $REMOTE_ADDR", "correo&#58;<$correo>\nReply-To&#58;<$correo>\nSender&#58;<$correo>"&#41;;
                    echo "$mess1\n";
                    echo "
    
     $thankz\n";
    
            &#125;
            elseif &#40;$ok == "false"&#41; &#123;
    ?>
    <form method="POST" action="<? echo $PHP_SELF ?>">
            <? echo $emailadress."&#58; ".$erb ?>
    
            <input type="text" name="correo" size="30" value="<? echo $correo ?>" maxlength="30">
    
            <? echo $saywhat."&#58; ".$erc ?>
    
            <textarea rows="10" name="comentarios" cols="50"><? echo $comentarios ?></textarea>
    
    
    		<? echo $antispam."&#58; ".$erd ?>
    
    		<? echo '![image](ic.php?a=',$imf,')
     <input id="code" name="code"  />
     <input id="code2" name="code2" type="hidden" value="', $id&#91;0&#93; ,'" />
    <input type="hidden" name="send" value="ok">
    
    <input type="submit" value="Enviar">
    <input type="reset" value="Borrar">
    </form>';
    ?>
    
    
    
    <?
            &#125;
    &#125;
    else &#123;
    ?>
    <form method="POST" action="<? echo $PHP_SELF ?>">
            <? echo $emailadress ?>&#58;
    
            <input type="text" name="correo" size="27">
    
            <? echo $saywhat ?>&#58;
    
            <textarea rows="10" name="comentarios" cols="40"></textarea>
    
    
    <? echo $antispam ?>
    
    		<? echo '![image](ic.php?a=',$imf,')
     <input id="code" name="code"  />
     <input id="code2" name="code2" type="hidden" value="', $id&#91;0&#93; ,'" />
    <input type="hidden" name="send" value="ok">
    
    <input type="submit" value="Enviar">
    <input type="reset" value="Borrar">
    </form>
    ';
    &#125;
    ?>
    </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