Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax reCaptcha post and insert into database
    primarykey
    data
    text
    <p>Hello i have an recaptcha working with ajax but it's not inserting my form infos into database, it inserts empty rows and i dont have any clue why Here is my code:</p> <pre><code> require_once('inc/recaptchalib.php'); $publickey = "6LdW1N0SAAAAADMIPPkOGd939meXV9a9qDwwcxbu"; // you got this from the signup page $privatekey = ""; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var RecaptchaOptions = { theme : 'clean' }; &lt;/script&gt; &lt;script type="text/javascript"&gt; function validateCaptcha() { challengeField = $("input#recaptcha_challenge_field").val(); responseField = $("input#recaptcha_response_field").val(); //alert(challengeField); //alert(responseField); //return false; var html = $.ajax({ type: "POST", url: "ajax.recaptcha.php", data: "recaptcha_challenge_field=" + challengeField + "&amp;recaptcha_response_field=" + responseField, async: false }).responseText; if(html == "success") { $("#captchaStatus").html("Success. Submitting form."); return false; // Uncomment the following line in your application //return true; } else { $("#captchaStatus").html("Your captcha is incorrect. Please try again"); Recaptcha.reload(); return false; } } &lt;/script&gt; </code></pre> <p>Here is the form that i want to insert into database:</p> <pre><code>&lt;form id="loginform" name="loginform" action="" method="post" enctype="multipart/form-data" onSubmit="return validateCaptcha()" &gt; &lt;fieldset class="step"&gt; &lt;p&gt; &lt;label for="nick"&gt;Nickname:&lt;/label&gt; &lt;input type="text" name="nick" value="" id="nicknamee" value="" &gt; &lt;/p&gt; &lt;p&gt; &lt;label for="email"&gt;Email:&lt;/label&gt; &lt;input type="text" name="email" value="" id="email_comm" value="" &gt; &lt;/p&gt; &lt;p&gt; &lt;textarea class="text-input textarea wysiwyg" name="add_comment" id="text_commentt"&gt;&lt;/textarea&gt; &lt;/p&gt;';?&gt; &lt;div id="login"&gt; &lt;?php echo recaptcha_get_html($publickey);?&gt; &lt;p style="color: red;" id="captchaStatus"&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt; &lt;?php echo' &lt;p style="margin-top:200px;"&gt;&lt;button id="vote_petiton_submit" type="submit" &gt;&lt;/button&gt; &lt;/p&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p>Now the verification of the reCaptcha and database insert file. Validation is ok just inserting datas in database not working proper, it doesnt post the values.</p> <pre><code>&lt;?php require_once('inc/recaptchalib.php'); require_once('engine/db.php'); $publickey = "6LdW1N0SAAAAADMIPPkOGd939meXV9a9qDwwcxbu"; // you got this from the signup page $privatekey = ""; mysql_query("SET NAMES utf8"); $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp-&gt;is_valid) { ?&gt;success&lt;? $nick=$_REQUEST['nick']; $type=0; $email=$_REQUEST['email']; $descr=$_REQUEST['add_comment']; $descriere=strip_tags($descr,'&lt;br&gt;&lt;p&gt;&lt;a&gt;&lt;i&gt;&lt;u&gt;&lt;b&gt;'); $id=150; $insert = "INSERT INTO comments (`nickname`,`desc`,`email`,`type`,`id_pet_dem_des`) VALUES ('$nick','$descriere','$email','$type',$id)"; $result = mysql_query($insert) or die("query failed: " . mysql_error()); $queryz = "update petition set comments=comments+1 where id_petition='$id'"; $resultz = mysql_query($queryz) or die("query failed: " . mysql_error()); } else { die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp-&gt;error . ")"); } ?&gt; </code></pre> <p>Thnx in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload