2016-09-19 108 views
-1

我需要一些幫助,我實現谷歌驗證碼到一個PHP的網站,意外的文件結尾,但整理的代碼,並上傳後,顯示此錯誤:PHP獲得對谷歌的reCAPTCHA

Parse error: syntax error, unexpected end of file in /home/cbj/public_html/2016/solicitudForm.php on line 29

現在,這裏是我的代碼爲recaptcha

<?php 
    $memberType;$name;$email;$phone;$address;$captcha; 
    if(isset($_POST['memberType'])){ 
     $memberType=$_POST['memberType']; 
    } 
    if(isset($_POST['name'])){ 
     $name=$_POST['name']; 
    } 
    if(isset($_POST['email'])){ 
     $email=$_POST['email']; 
    } 
    if(isset($_POST['phone'])){ 
     $phone=$_POST['phone']; 
    } 
    if(isset($_POST['address'])){ 
     $address=$_POST['address']; 
    } 
    if(isset($_POST['g-recaptcha-response'])){ 
     $captcha=$_POST['g-recaptcha-response']; 
    } 
    if(!$captcha){ 
     echo '<div class="alert alert-warning"> 
       Por favor, verifica que seas humano 
      </div>'; 
     exit; 
    } 
    $secretKey = "6LeEECoTAAAAAGLUBgHQ_OC-ZYJi0Sj2b_1JPRUx"; 
    $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha); 
    $responseKeys = json_decode($response,true); 
    if(intval($responseKeys["success"]) !== 1) { 
     echo '<h2>You are spammer ! Get the @$%K out</h2>'; 
    } else { 
     echo '<h2>Thanks for posting comment.</h2>'; 
    } 
?> 

任何幫助,不勝感激,謝謝。

+1

縮進和折斷線條只是無禮的。難怪你有語法錯誤。 – PeeHaa

+0

對不起,如果堆棧溢出複製/粘貼給你的眼睛問題,只是錯誤出現在最後一行,所以...你有答案嗎? –

+0

這與堆棧溢出複製粘貼無關,而與您的代碼有關。順便說一句,這也是錯誤來自你現在正面臨的問題。 – PeeHaa

回答

-1

由於某種原因,在本地PC上沒有檢測到(甚至沒有保存)最後一個分號,直接在服務器上寫代碼使工作。