Note that there are some explanatory texts on larger screens.

plurals
  1. POway to have php header open same page but showing a hidden div?
    text
    copied!<p>Apologies if this has been asked before, but I am working on my first site and still learning. I am trying to add a captcha to the contact form taken from here <a href="http://www.captcha.net/" rel="nofollow">http://www.captcha.net/</a> and using PHP. At the moment it is working, but the code supplied on the site for it to work is as follows:</p> <pre><code> &lt;html&gt; &lt;body&gt; &lt;!-- the body tag is required or the CAPTCHA may not show on some browsers --&gt; &lt;!-- your HTML content --&gt; &lt;form method="post" action="verify.php"&gt; &lt;?php require_once('recaptchalib.php'); $publickey = "your_public_key"; // you got this from the signup page echo recaptcha_get_html($publickey); ?&gt; &lt;input type="submit" /&gt; &lt;/form&gt; &lt;!-- more of your HTML content --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and the verify code for it on a different file (server side) is:</p> <pre><code> &lt;?php require_once('recaptchalib.php'); $privatekey = "your_private_key"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp-&gt;is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp-&gt;error . ")"); } else { // Your code here to handle a successful verification } ?&gt; </code></pre> <p>What I am wondering is if there is a way to have the if statement (if the captcha is wrong) open the contact page but show a hidden div displaying that the captcha code is wrong and try again.</p>
 

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