Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For validating Captcha twice via AJAX/Jquery and on a server page, this is my technique with PHP (the basic idea is just to restore Captcha's Session Variables cleared by the Captcha Check method if correct captcha entered on client side validation, so they will be there again for server side validation): </p> <ol> <li><p>The following may look confusing as it is one of my lazy way of reusing the client side validation on both the HTML form and the HTML form's action page.</p></li> <li><p>On the HTML form, add an additional POST variable (e.g. $_POST["task"] = "validate" which is not an input element in the form which will be passed on form submission to the client side validation PHP page</p> <pre class="lang-js prettyprint-override"><code>$.ajax({ type: "POST", url: "registration_validate.php", data: ({ task:"validate" &lt;&lt; and other data &gt;&gt; </code></pre></li> <li><p>On the client side validation PHP page</p> <pre class="lang-php prettyprint-override"><code>$securimage_session_cv = $_SESSION["securimage_code_value"]["default"]; $securimage_session_ct = $_SESSION["securimage_code_ctime"]["default"]; if ($securimage-&gt;check($_POST['captcha_code']) == false) { // return false or print something } else { // if this script is called via ajax for form validation if(isset($_POST['task']) &amp;&amp; trim($_POST['task']) == "validate"){ // captcha will be cleared if valid/correct, restore them as it will be validated again on server side script $_SESSION["securimage_code_value"]["default"] = $securimage_session_cv; $_SESSION["securimage_code_ctime"]["default"] = $securimage_session_ct; } } </code></pre></li> <li><p>On the server side validation page or form action url, you will have the Captcha Session intact for validation.</p></li> </ol>
    singulars
    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.
    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