Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2004
    residenza
    Parma
    Messaggi
    104

    re captcha in form registrazione

    Un saluto a tutta la comunità, ho cercato a lungo e non ho trovato nulla che mi possa aiutare, anche perchè quello che ho trovato in giro parla solo di form della pagina contatti.

    Ho necessità d'inserire il controllo captcha nella pagina di registrazione del mio sito, la pagina è costituita da due file il primo è signup.php nel quale c' è il form di registrazione e nel quale ho inserito la stringa per visualizzare il winget :

    <?php
    require_once(dirname(__FILE__) . '/libs/b3.php');
    require_once(dirname(__FILE__) . '/libs/GRS.function.php');
    $headertitle = "Crea un Nuovo Account";include('header.php');
    if ($_SERVER['QUERY_STRING'] == 'terms') {
    uheader();
    echo("<div align=center class=\"big\">Termini e Condizioni</div>\n");
    $res = mysql_query("select content from html where type='terms'");
    $terms = mysql_result($res, 0, "content");
    echo($terms);
    ufooter();
    } else {
    $res = mysql_query("select content from html where type='head1'");
    $hf = mysql_result($res, 0, "content");
    echo($hf);
    if ($form == 'sent') {
    $checkpass = 'true';
    $error = '<div align=center><font face=$fontface color=red size=2><b>Per favore correggere i seguenti punti:<br>';
    if (ereg('%', $name) || ereg('<', $name) || ereg('>', $name)) {
    $error = $error . 'Il Vostro nome contiene caratteri non accettati<br>';
    $checkpass = 'false';
    }
    if ($name == "") {
    $error = $error . 'Inserire il proprio nome<br>';
    $checkpass = 'false';
    }
    $trimail = trim($email1);
    $res = mysql_query("select count(*) from user where email='$trimail1'");
    if (mysql_result($res, 0) != 0) {
    $error = $error . 'La E-mail inserita &eacute; gi&agrave; in uso<br>';
    $checkpass = 'false';
    }
    if (!ereg('@', $email1) || !ereg('.', $email1)) {
    $error = $error . 'La E-mail inserita non &eacute; valida<br>';
    $checkpass = 'false';
    }
    if ($email1 != $email2) {
    $error = $error . 'Il tuo indirizzo e-mail non corrisponde<br>';
    $checkpass = 'false';
    }
    if ($passwd == "") {
    $error = $error . '&Egrave; necessario inserire la password<br>';
    $checkpass = 'false';
    } elseif (strlen($passwd) < 6) {
    $error = $error . 'La password deve essere lunga almeno 6 caratteri<br>';
    $checkpass = 'false';
    }
    if (ereg('%', $passwd) || ereg(' ', $passwd)) {
    $error = $error . 'La tua password contiene caratteri non accettati<br>';
    $checkpass = 'false';
    }
    if ($C->sfrfvi('count(*)', 'user', 'where email="'.addslashes($email1).'"') === 1) {
    $error = $error . 'L\'indirizzo e-mail &eacute; gi&agrave; registrato<br>';
    $checkpass = 'false';
    }
    /*
    check the signup ip. it must not be used before. it it has been used, then the user can't sign up.
    Hardi. 21.07.2008 10:21
    IPB
    */
    if ($Cuscus->sfrfvi('COUNT(*)', 'user', 'where activate_IP = "' . $_SERVER['REMOTE_ADDR'] . '"')) {
    $error .= 'Questo IP &eacute; gi&agrave; stato utilizzato<br>';
    $checkpass = 'false';
    }
    //eo IPB
    if ($termscheck != 1) {
    $error = $error . '&Eacute; necessario controllare e accettare le nostre condizioni<br>';
    $checkpass = 'false';
    }
    if ($checkpass != 'true') {
    $error = $error . '</font></b></div>';
    echo($error);
    }
    }
    if ($checkpass != 'true') {
    echo("<table border=0 cellpadding=5 cellspacing=0 width=100%><form action=$PHP_SELF method=post name=nu><input type=hidden name=form value=sent>\n");
    if (isset($ref) && is_numeric($ref)) {
    echo("<input type=hidden name=ref value=$ref>");
    }
    echo("<tr><td class=boxtext width=50% align=right valign=top><font >Il Vostro Nome:</td><td class=boxtext width=50% align=left valign=top><input value=\"$name\" type=text name=name size=20 maxlength=100></td></tr>\n");
    echo("<tr><td class=boxtext align=right valign=top><font >Indirizzo E-mail:</td><td class=boxtext align=left valign=top><input value=\"$email1\" type=text name=email1 size=20 maxlength=100></td></tr>\n");
    echo("<tr><td class=boxtext align=right valign=top><font >Conferma indirizzo E-mail:</td><td class=boxtext align=left valign=top><input value=\"$email2\" type=text name=email2 size=20 maxlength=100></td></tr>\n");
    echo("<tr><td class=boxtext align=right valign=top><font >Password:</td><td class=boxtext align=left valign=top><input value=\"$passwd\" type=password name=passwd size=20 maxlength=20></td></tr>\n");
    echo("<tr><td class=boxtext align=center valign=top colspan=2><input type=checkbox");
    if ($termscheck == 1) {echo(" checked");}
    echo(" name=termscheck value=1><font > Accetto i <a href=terms.php target=_blank><b><font>termini e condizioni</b></a></td></tr>\n");
    echo("<tr><td class=boxtext align=center valign=top colspan=2><b><font ><b><font color=red>Importante:</font></b> Il tuo sito non deve avere finestre pop-up,<br> non deve spezzare il frames e non deve <br>utilizzare l'inoltro o reindirizzare! <br> NO a MUSICA, SUONI e/o FILMATI che si attivano automaticamente.</b></td></tr>\n");
    echo("<tr><td class=boxtext align=center valign=top colspan=2><input type=submit value=\"Registra!\"></td></tr>\n");
    echo("<tr><td class=g-recaptcha data-sitekey=CHIAVE-DEL-SITO align=center valign=top colspan=2></td></tr>\n");
    echo("</form></table>\n");
    } else {
    srand((double)microtime()*1000000);
    $ac = rand(1000, 10000);
    $name = trim($name);
    $email = trim($email1);
    $sitename = trim($sitename);
    $name = addslashes($name);
    $sitename = addslashes($sitename);
    $res = mysql_query("select value from adminprops where field='inibon'");
    $inibon = mysql_result($res, 0, "value");
    if (!isset($ref) || !is_numeric($ref)) {$ref=0;}
    $date = date("Y-m-d H:i:s");
    $secid = GRS(10);
    $res = mysql_query("insert into user (name, email, passwd, ref, acctype, credits, joindate, minmax, lastaccess, ac, secid) values ('$name', '$email', '$passwd', $ref, 1, 0, '$date', 1, '$date', $ac, '$secid')");
    $usrid = mysql_insert_id();
    $surpres = mysql_query("update adminprops set value=value-$inibon where field='surplu'");
    $res = mysql_query("select value from admin where field='email'");
    $admail = mysql_result($res, 0, "value");
    if ($ref != 0) {
    $getrefemail = mysql_query("select email from user where id=$ref");
    if (mysql_num_rows($getrefemail) !=0) {
    $refemail = mysql_result($getrefemail, 0, "email");
    mail($refemail, "Nuovo Referente $title", "Salve, un nuovo referente si � aggiunto $title alla Vostra linea!\n\nGrazie per aver promosso la Vostra $title referente URL!\n\n$title Admin\nhttp://$siteurl/\n$admail", "From: \"$title Admin\" <$admail>");
    }
    }
    mail($email, "Grazie per esserti Registrato a $title!", "$name, Grazie per la tua Registrazione!\n\nIl Vostro $title login �: $email\nLa Vostra $title password �: $passwd\n\nPer attivare il Vostro account cliccare sul seguente link:\n$self_url" . "activate.php?ac=$ac&i=$usrid\n o copiate nel Vostro browser la seguente stringa.\n\nIl Vostro link per i referenti �:\nhttp://$siteurl?ref=$usrid\nSi guadagnano 0,1 credito ogni volta che il Vostro referente visualizza un sito!\n\nAttivando l'account, l'utente accetta di ricevere e-mail in futuro. � possibile interrompere la ricezione cancellando l'account.\n\n$title Admin\nhttp://$siteurl/\n$admail", "From: \"$title Admin\" <$admail>");
    echo("<p align=center class=\"big\">Grazie per la registrazione!</p>");
    echo("<p align=center>Il link di attivazione del tuo account &eacute; stato inviato a $email.</p>");
    }
    ufooter();
    }
    include('footer.php');
    ?>
    < ?php
    $time = date('d/m/Y H:i:s');
    $fp = fopen('logs.txt', 'a+');
    fwrite($fp, "{$time} | {$_SERVER['REMOTE_ADDR']} | {$_SERVER['HTTP_USER_AGENT']}\n");
    fclose($fp);
    echo 'Le informazioni sono state salvate correttamente!';
    ?>
    Nello stesso file c' è il richiamo a header.php nel quale inserisco la seconda stringa prima del </head>.

    Ora devo inserire il controllo che invia a Google la richiesta di controllo del recaptcha

    <?php
    if(isset($_POST['name'])){

    $name=$_POST['name'];
    $g_resp=$_POST['g-recaptcha-response'];

    $secret="CHIAVE SEGRETA"; // Secret key provided by google
    $postdata="secret=".$secret."&response=".$g_resp; // we will post the data to the google
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,"https://www.google.com/recaptcha/api/siteverify");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $server_output = curl_exec($ch); // response from the google
    $out=json_decode($server_output);
    curl_close ($ch);
    if($out->success ==1){
    // after success
    // place your code here what you want to do.
    echo "capcha sucess <br>";
    echo $name;

    }else{
    // failure
    // place the fail code.
    echo "captcha failure try again";
    }
    }

    ?>
    e qui mi fermo perchè non ho capito in quale dei due file inserirlo e in che posizione, avendo provato a posizionarlo in testa, all'inizio dei file, in tutti e due ma non funziona se faccio una prova di registrazione e invio senza spuntare il captcha l'iscrizione va a buon fine.

    Grazie in anticipo per l'aiuto come avete capito mi sono perso in un bicchier d'acqua.
    Mors ego sum mortis, vocor Agnus sum Leo fortis

  2. #2
    Utente di HTML.it
    Registrato dal
    Dec 2004
    residenza
    Parma
    Messaggi
    104
    In 18 giorni nessuna aiuto, possibile che nessuno sappia perché non funziona e come sistemarlo?
    Mors ego sum mortis, vocor Agnus sum Leo fortis

Tag per questa discussione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.