2016-12-22 5 views
1

ReCaptcha가 검증되었는지 여부에 상관없이 양식이 여전히 제출되기 때문에 ReCaptcha를 추가하려는 양식이 있습니다.양식이 reCaptcha를 확인하지 않습니다

<?php if(isset($_GET[ 'CaptchaPass'])){ ?> 
<div>Thank you! Your Form was Successfully Submitted</div> 
<?php } ?> 
<?php if(isset($_GET[ 'CaptchaFail'])){ ?> 
<div>Captcha Error. Please verify that you are human!</div> 
<?php } ?> 
<form action="http://vmobileautoglass.com/php/func_contact.php"> 
    <label>Name</label> <span class="color-red">*</span> 
    <div class="row margin-bottom-20"> 
     <div class="col-md-6 col-md-offset-0"> 
      <input class="form-control" type="text" name="name"> 
     </div> 
    </div> 
    <label>Email 
     <span class="color-red">*</span> 
    </label> 
    <div class="row margin-bottom-20"> 
     <div class="col-md-6 col-md-offset-0"> 
      <input class="form-control" type="text" name="email"> 
     </div> 
    </div> 
    <label>Phone 

    </label> 
    <div class="row margin-bottom-20"> 
     <div class="col-md-6 col-md-offset-0"> 
      <input class="form-control" type="text" name="phone"> 
     </div> 
    </div> 
    <label>Message</label> <span class="color-red">*</span> 
    <div class="row margin-bottom-20"> 
     <div class="col-md-8 col-md-offset-0"> 
      <textarea rows="8" class="form-control" name="message"></textarea> 
     </div> 
    </div> 
    <div class="g-recaptcha" data-sitekey="MYSITEKEYFROMGOOGLE"></div> 
    <p> 
     <button type="submit" class="btn btn-primary" name="ContactButton">Send Message</button> 
    </p> 
</form> 

이 양식이있는 페이지의 맨 위에 간다 :

<?php 

if (isset($_POST['ContactButoon'])) { 

    $url = 'https://google.com/recaptcha/api/siteverify'; 
    $privatekey = "MYPRIVATEKEYFROMGOOGLE"; 

    $response = file_get_contents($url . "?secret=" . $privatekey . "&response=" . $_POST['g-recaptcha-response'] . "&remoteip=" . $_SERVER['REMOTE_ADDR']); 
    $date = json_decode($response); 

    if (isset($data->success) AND $data->success == true) { 
     header('Location: contact.php?CaptchaPasss=True'); 
    } else { 
     header('Location: contact.php?CaptchaFail=True'); 
    } 
} 
?> 

그리고이 양식 기능입니다 :

// Receiving variables 
@$pfw_ip = $_SERVER['REMOTE_ADDR']; 
@$name = addslashes($_GET['name']); 
@$email = addslashes($_GET['email']); 
@$phone = addslashes($_GET['phone']); 
@$message = addslashes($_GET['message']); 

// Validation 
if (strlen($name) == 0) { 
    header("Location: http://vmobileautoglass.com/php/err_name.php"); 
    exit; 
} 

if (strlen($email) == 0) { 
    header("Location: http://vmobileautoglass.com/php/err_email.php"); 
    exit; 
} 

if (strlen($message) == 0) { 
    header("Location: http://vmobileautoglass.com/php/err_message.php"); 
    exit; 
} 

//Sending Email to form owner 
$pfw_header = "From: $email\n" 
     . "Reply-To: $email\n"; 
$pfw_subject = "vMobile Contact Form"; 
$pfw_email_to = "[email protected]"; 
$pfw_message = "Visitor's IP: $pfw_ip\n" 
     . "name: $name\n" 
     . "email: $email\n" 
     . "phone: $phone\n" 
     . "message: $message\n"; 
@mail($pfw_email_to, $pfw_subject, $pfw_message, $pfw_header); 

header("Location: http://vmobileautoglass.com/php/successform.php"); 

양식입니다

답변

1

오타가 있습니다.

$date = json_decode($response); 

    if(isset($data->success) AND $data->success==true){ 

$ date는 $ data 여야합니다.

+0

감사합니다. 고정되었지만 문제가 지속됩니다. –

+0

더 많은 정보를 제공해주세요. $ response 변수가 배열입니까? – Illuminati

관련 문제