2016-06-01 19 views
0

Ich benutze Google Recaptcha, und ich habe mit diesem Stück Code am Ende. Mein Ziel ist es, mein bereits funktionierendes PHP-Formular erst nach Abschluss des Captchas einreichen zu lassen. Jede Hilfe wäre willkommen.CAPTCHA Integration in bestehende PHP Formular

<?php 
if (isset($_POST['ContactButton'])) { 
    $url = 'https://www.google.com/recaptcha/api/siteverify'; 
    $privatekey = "6LePayETAAAAANJze7opnV6bQEX-n02p4UdZ8xfF"; 
    $response = file_get_contents($url . "? 
     secret=" . $privatekey . "&response" . $_POST['g-recaptcha- 
     response'] . "&remoteip=" . $_SERVER['REMOTE_ADDR']); 
    $data = json_decode($respose); 
    if (isset($data -> success) AND $data -> success == true) { 
     $name = $_POST['name']; 
     $email = $_POST['email']; 
     $phone = $_POST['phone']; 
     $message = $_POST['message']; 
     $formcontent = " From: $name \n Phone: $phone \n Message: $message"; 
     $recipient = "[email protected]"; 
     $subject = "Contact Form"; 
     $mailheader = "From: $email \r\n"; 
     mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); 
     header('Location: contact-thank-you.html'); 
     exit(); 
    } else { 
     header('location: index.html?captchafail=True'); 
    } 
} 
?> 
+0

Können Sie erklären, was nicht funktioniert über es? – thesecretmaster

Antwort