开发者

reCAPTCHA with integrated PHP [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

I try use reCaptcha and integrated with php, so if code is correct email will sent. So my problem here, when I type code wrong, the message show wrong code, that correct but when I type correct code their will go to successsful page also correct but I not receive any email.

*I think is maybe I put my script in wrong place (between if else).

<?php
  require_once('recaptchalib.php');
  $privatekey = "xxxxxxxxxxxxxxxxxxxxxxxx";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {

 die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
         "(reCAPTCHA said: " . $resp->error . ")");

  } else {

$full_name= $_POST["full_name"];
$email= $_POST["email"];
$address1= $_POST["address1"];
$address2= $_POST["address2"];
$postcode= $_POST["postcode"];
$city= $_POST["city"];
$state= $_POST["state"];
$country= $_POST["country"];
$telephone= $_POST["telephone"];
$month= $_POST["month"];
$birthday= $_POST["birthday"];
$birthyear= $_POST["birthyear"];

require_once('lib/class.phpmailer.php');

$mail             = new PHPMailer(); // defaults to using php "mail()"
$mail->SetFrom('ruslyrossi46@gmail.com');
$mail->AddReplyTo("ruslyrossi46@gmail.com");
$address = "ruslyrossi46@gmail.com";
$mail->AddAddress($address);
$mail->Subject    = "FLOW";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->Body = "Sign Up Details<br><br> 
-------------------------------------------------------------<br>
First Name : $full_name<br>
Address : $address1<br>  
Alternate Address : $address2<br> 
Postcode : $postcode<br> 
State : $state<br> 
City : $city<br> 
Country : $country<br> 
开发者_StackOverflow中文版Phone Number :  $telephone<br> 
Email : $email<br> 
Birth Of Day :  Day:$birthday  Month:$month Years:$birthyear<br> 

Thank You!<br>

------------------------------------------------------------<br>
";
  }

?>


You missed

if($mail->Send())  
{ 
    echo 'sent'; 
}  
else  
{ 
    echo 'error'; 
}

at the end (inside the else as last thing)

This is just an example, customize it as your needs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜