ReCaptcha

Gestart doorFreestyle5 reacties22 weergaven

6 berichten · pagina 1 van 1

Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik ben bezig met een captcha voor mijn contact formulier. alleen ik snap ReCaptcha niet helemaal.
Ik heb die code maar ik krijg heletijd een error.

Code:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
                                      [URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]recaptchalib.php[/COLOR][COLOR= #007700]);[/COLOR]

                                    [COLOR= #FF8000]// Get a key from https://www.google.com/recaptcha/admin/create[/COLOR]
                                    [COLOR= #0000BB]$publickey[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"hier mijn public key"[/COLOR][COLOR= #007700];[/COLOR]
                                    [COLOR= #0000BB]$privatekey[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Hier mijn private key"[/COLOR][COLOR= #007700];[/COLOR]
                                    
                                    [COLOR= #FF8000]# the response from reCAPTCHA[/COLOR]
                                    [COLOR= #0000BB]$resp[/COLOR] [COLOR= #007700]=[/COLOR] null[COLOR= #007700];[/COLOR]
                                    [COLOR= #FF8000]# the error code from reCAPTCHA, if any[/COLOR]
                                    [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] null[COLOR= #007700];[/COLOR]
                                    
                                    [COLOR= #FF8000]# was there a reCAPTCHA response?[/COLOR]
                                    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"recaptcha_response_field"[/COLOR][COLOR= #007700]]) {[/COLOR]
                                            [COLOR= #0000BB]$resp[/COLOR] [COLOR= #007700]=[/COLOR] recaptcha_check_answer [COLOR= #007700]([/COLOR][COLOR= #0000BB]$privatekey[/COLOR][COLOR= #007700],[/COLOR]
                                                                            [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"REMOTE_ADDR"[/COLOR][COLOR= #007700]],[/COLOR]
                                                                            [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"recaptcha_challenge_field"[/COLOR][COLOR= #007700]],[/COLOR]
                                                                            [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"recaptcha_response_field"[/COLOR][COLOR= #007700]]);[/COLOR]
                                    
                                            [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$resp[/COLOR][COLOR= #007700]->[/COLOR]is_valid[COLOR= #007700]) {[/COLOR]
                                                    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"You got it!"[/COLOR][COLOR= #007700];
                                            }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                                                    [COLOR= #FF8000]# set the error code so that we can display it[/COLOR]
                                                    [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$resp[/COLOR][COLOR= #007700]->[/COLOR]error[COLOR= #007700];
                                            }
                                    }[/COLOR]
                                    [URL="http://www.php.net/echo"]echo[/URL] recaptcha_get_html[COLOR= #007700]([/COLOR][COLOR= #0000BB]$publickey[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700]);[/COLOR]
                                 ?>
Spoiler tonen
Error:

Notice: Undefined index: recaptcha_response_field in C:***********	est.php on line 14
Komt dit miss omdat ik hem in mijn localhost maak?
0
Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dit werkt niet:

if ($_POST["recaptcha_response_field"]) {
+ je hebt daar twee x variable gedaan ?
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Propje schreef:
Dit werkt niet:

if ($_POST["recaptcha_response_field"]) {
+ je hebt daar twee x variable gedaan ?
Dat is dan ook raar, want dat kom recht van google zo.
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kijk mijn tutorial eens door wink
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren