带有集成 PHP 的 reCAPTCHA
我尝试使用 reCaptcha 并与 php 集成,因此如果代码正确,将发送电子邮件。 所以我的问题在这里,当我输入错误的代码时,消息显示错误的代码,这是正确的,但是当我输入正确的代码时,他们将转到成功的页面,但我没有收到任何电子邮件。
*我想也许我把脚本放在了错误的地方(在 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('[email protected]');
$mail->AddReplyTo("[email protected]");
$address = "[email protected]";
$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>
Phone Number : $telephone<br>
Email : $email<br>
Birth Of Day : Day:$birthday Month:$month Years:$birthyear<br>
Thank You!<br>
------------------------------------------------------------<br>
";
}
?>
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('[email protected]');
$mail->AddReplyTo("[email protected]");
$address = "[email protected]";
$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>
Phone Number : $telephone<br>
Email : $email<br>
Birth Of Day : Day:$birthday Month:$month Years:$birthyear<br>
Thank You!<br>
------------------------------------------------------------<br>
";
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您
在最后错过了(在 else as last thing 内)
这只是一个示例,请根据您的需要进行自定义。
You missed
at the end (inside the else as last thing)
This is just an example, customize it as your needs.