Premettendo che non capisco assolutamente nulla di javascript, qualcuno può aiutarmi ad integrare il recaptcha di google a questo form che avevo costruito con i controlli in java?
Il form senza il captcha funziona, ma il form con il captcha invia i dati senza tener conto del captcha...
Il captcha senza il form funziona.
codice HTML:<? if(!isset($_POST['action'])){?> <script> <!-- function Modulo() { // Variabili associate ai campi del modulo var nome = document.modulo.nome.value; //Effettua il controllo sul campo NOME if ((nome == "") || (nome == "undefined")) { alert("Il campo Nome è obbligatorio."); document.modulo.nome.focus(); return false; } //INVIA IL MODULO else { document.modulo.action = "registrazione.php"; document.modulo.submit(); } } //--> </script> <table> <form method="post" name="modulo"> <tr> <td colspan="2" align="center"><div style="color:#FFF; font-size:20px;"><strong>Registrazione al servizio</strong></div><div style="color:#FFF">Tutti i campi, non contrassegnati con *,sono obbligatori</div> </td> </tr> <tr><td><div style="color:#FFF">Nome</div></td><td><input type="text" name="nome" id="nome"></td></tr> <tr> <td colspan="2" align="center"> <script type="text/javascript"> var RecaptchaOptions = { theme : 'blackglass' }; </script><?php error_reporting(E_ALL ^ E_NOTICE); require_once('recaptchalib.php'); // Get a key from https://www.google.com/recaptcha/admin/create $publickey = "6LebOugSAAAAAKmk_DDaAUIiJosuJ-o5iCsEbm-s"; $privatekey = "6LebOugSAAAAAJ6zfQ6syWE17uU0l9h8FcsoP2SE"; # the response from reCAPTCHA $resp = null; # the error code from reCAPTCHA, if any $error = null; # was there a reCAPTCHA response? if ($_POST["recaptcha_response_field"]) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { echo "<script>alert(\"Errore\"); </script>"; } } echo recaptcha_get_html($publickey, $error); ?></td> </tr> <tr> <td colspan="2" align="center"> <input name="action" type="hidden" id="action" value="save" /> <input type="button" value="Invia" onClick="Modulo()"></td></tr> </form> </table> <? }else{ $data = date('Y-m-d'); $email = $_POST['email']; $email_control = mysql_query("SELECT user FROM utenti_login WHERE user = '$email'"); if(mysql_num_rows($email_control)) { print "<div style=\"color: white\">Hai già utilizzato questo indirizzo mail. <br/>Se non ricordi la password, richiedila qui.</div>"; } else { mysql_query("INSERT INTO utenti_login (user,password, gruppo) VALUES ('".addslashes($_POST['email2'])."','".addslashes($_POST['password'])."','2')") or die (mysql_error()); $id=mysql_insert_id(); mysql_query("INSERT INTO utenti_dati (id, societa, nome, cognome, email, citta, indirizzo, cap, telefono, data_registrazione, codicefiscale, stato, provincia, piva) VALUES ('".$id."', '".addslashes($_POST['societa'])."', '".addslashes($_POST['nome'])."', '".addslashes($_POST['cognome'])."', '".addslashes($_POST['email'])."', '".addslashes($_POST['citta'])."', '".addslashes($_POST['indirizzo'])."', '".addslashes($_POST['cap'])."', '".addslashes($_POST['telefono'])."', '".$data."', '".addslashes($_POST['codicefiscale'])."', '0', '".addslashes($_POST['provincia'])."', '".addslashes($_POST['piva'])."')") or die (mysql_error()); echo "<span class=\"text_prodotti_blue\" style=\"color:#FFF\">Registrazione avvenuta con successo!</span>"; } }?>


Rispondi quotando