Add the google reCAPTCHA verification code to the website for enhanced verification

Source: Internet
Author: User
Tags php template

Step 1 Registration

Step 2: Get the api and embed the code into the relevant webpage.

First, enter the code in the template, that is, the report. php template on the form submission page.

<Tr> <td height = "23"> Captcha </td> <td height = "23"> <? Php require_once ('.. /.. /.. /skin/google/recaptchalib. php '); $ publickey = "Enter the applied apikey, Public Key"; echo recaptcha_get_html ($ publickey);?> </Td> </tr>

Next we will post the code to the relevant page.

E/enews/index. php code at the top

<? Phprequire_once ('.. /.. /skin/google/recaptchalib. php '); $ privatekey = "the key you applied for"; $ resp = recaptcha_check_answer ($ privatekey, $ _ SERVER ["REMOTE_ADDR"], $ _ POST ["recaptcha_challenge_field"], $ _ POST ["recaptcha_response_field"]); if (! $ Resp-> is_valid) {die ("Incorrect !! <A href = '# 'onclick = 'javascript: history. back (-1);'> Click here to back! </A> "." (reCAPTCHA said: ". $ resp-> error .")");}

Finally, you need to download the recaptchalib. php file used in the above file.

Put it under the relevant file directory. OK.

Check whether the effect is correct in the next few days.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.