2016-07-26 10 views
2
<?php 
if(isset($_POST['submit'])) 
{ 
$email=$_POST['email']; 
$comment=$_POST['comment']; 
$captcha=$_POST['g-recaptcha-response']; 
if(!$captcha) 
{ 
    echo 'Please check the the captcha form.'; 
} 

$response=file_get_contents("https://www.google.com/recaptcha/api/sitev erify?secret="secretkey"  &response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']); 

if($response.success==false) 
{ 
    header('Location:http://mywebsite.com/.errordocs/404.html'); 
} 
else 
{ 
    header('Location:http://mywebsite.com/thankyou.php'); 
} 
} 

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

$name = $_POST['name']; 

$last = $_POST['last']; 

$email = $_POST['email']; 

$phone = $_POST['phone']; 

$comments = $_POST['comments']; 
// Build the email (replace the address in the $to section with Enjoy's contact e-mail) 

$to = '[email protected]'; 

$subject = "Main Contact Form"; 

$message = "Name: $name 

Email: $email 

Phone: $phone 

Comments: $comments"; 

$headers = "From: $email \r\n"; 

mail($to, $subject, $message, $headers); 
} 
?> 

問題はrecaptchaがフォーム上で確認され、チェックマークが表示され、ユーザーは送信をクリックできますが、空白の画面が表示され、電子メールは送信されません。どんな助けもありがとうございます。これについて約3週間作業しています。recaptchaはPHPで確認後にメールを送信しません

+2

あなたが任意の電子メール –

答えて

1

実際にメールを送信する前に現在リダイレクトしています。ここであなたのコードが再構成されます。また、ヘルプのために多くの感謝をreCAPTCHAの応答処理

<?php 
if (isset($_POST['submit'])){ 
    $email = $_POST['email']; 
    $comment = $_POST['comment']; 
    $captcha = $_POST['g-recaptcha-response']; 
    if (! $captcha){ 
     echo 'Please check the the captcha form.'; 
     exit(); 
    }else{ 

     $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $secretkey . "&response=" . $captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']); 

     $responseKeys = json_decode($response,true); 
     if (intval($responseKeys["success"]) !== 1){ 
      header('Location:http://mywebsite.com/.errordocs/404.html'); 
      exit(); 
     }else{ 


      if (isset($_POST['Side_Form'])){//not sure what this is, hopefully you do :-) 

       $name = $_POST['name']; 

       $last = $_POST['last']; 

       $email = $_POST['email']; 

       $phone = $_POST['phone']; 

       $comments = $_POST['comments']; 
       // Build the email (replace the address in the $to section with Enjoy's contact e-mail) 

       $to = '[email protected]'; 

       $subject = "Main Contact Form"; 

       $message = "Name: $name 
Email: $email 
Phone: $phone 
Comments: $comments"; 

       $headers = "From: $email \r\n"; 

       mail($to,$subject,$message,$headers); 
       header('Location:http://mywebsite.com/thankyou.php'); 
       exit(); 
      } 
     } 
    } 
} 
?> 
+0

ねえを送るbeforページからリダイレクトするための固定!提供されたコードを貼り付けましたが、今このエラーが発生します: 構文解析エラー:予期しない構文エラー '6'(T_LNUMBER) –

関連する問題