Php 如何应用recaptcha?
最近,垃圾邮件越来越多 所以,我想知道如何应用recaptcha 代码附在下面 我自己问你问题 请回复。多谢各位Php 如何应用recaptcha?,php,recaptcha,Php,Recaptcha,最近,垃圾邮件越来越多 所以,我想知道如何应用recaptcha 代码附在下面 我自己问你问题 请回复。多谢各位 <div class="letterbox"> <form method="post" name="enewsform" id="enewsform" action="enewsletter_ins.php"> <h3 class="tit2">Subscribe To
<div class="letterbox">
<form method="post" name="enewsform" id="enewsform" action="enewsletter_ins.php">
<h3 class="tit2">Subscribe To Newsletter</h3>
<div style="margin-top:10px;">
<label class="tit2">Name
<input type="text" name="name" value="" /></label>
<label class="tit2">Email Address
<input type="text" name="email" value="" /></label>
<input type="button" value="subscribe" class="btn_letter" onclick="sendData(document.enewsform)" />
<div class="g-recaptcha" data-sitekey="site_key"></div>
</div>
</form>
<script type="text/javascript">
<!--
function sendData(f){
if(f.name.value==""){
alert("Required to name.");
f.name.focus();
return false;
}
if(f.email.value==""){
alert("Required to email.");
f.email.focus();
return false;
}
if (f.email.value.search(/(\S+)@(\S+)\.(\S+)/) == -1 ) {
alert("Not Valid Email.");
f.email.focus();
return false;
}
f.submit();
}
//-->
<div class="letterbox">
<form method="post" name="enewsform" id="enewsform" action="enewsletter_ins.php">
<h3 class="tit2">Subscribe To Newsletter</h3>
<div style="margin-top:10px;">
<label class="tit2">Name
<input type="text" name="name" value="" /></label>
<label class="tit2">Email Address
<input type="text" name="email" value="" /></label>
<input type="button" value="subscribe" class="btn_letter" onclick="sendData(document.enewsform)" />
<?php
require_once('recaptchalib.php');
$publickey = "your_public_key"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
</div>
</form>
订阅时事通讯
名称
电子邮件地址
下载recaptcha PHP文件:
然后简单地把它放在你的HTML中
最近,垃圾邮件越来越多
所以,我想知道如何应用recaptcha
代码附在下面
我自己问你问题
请回复。多谢各位
<div class="letterbox">
<form method="post" name="enewsform" id="enewsform" action="enewsletter_ins.php">
<h3 class="tit2">Subscribe To Newsletter</h3>
<div style="margin-top:10px;">
<label class="tit2">Name
<input type="text" name="name" value="" /></label>
<label class="tit2">Email Address
<input type="text" name="email" value="" /></label>
<input type="button" value="subscribe" class="btn_letter" onclick="sendData(document.enewsform)" />
<div class="g-recaptcha" data-sitekey="site_key"></div>
</div>
</form>
<script type="text/javascript">
<!--
function sendData(f){
if(f.name.value==""){
alert("Required to name.");
f.name.focus();
return false;
}
if(f.email.value==""){
alert("Required to email.");
f.email.focus();
return false;
}
if (f.email.value.search(/(\S+)@(\S+)\.(\S+)/) == -1 ) {
alert("Not Valid Email.");
f.email.focus();
return false;
}
f.submit();
}
//-->
<div class="letterbox">
<form method="post" name="enewsform" id="enewsform" action="enewsletter_ins.php">
<h3 class="tit2">Subscribe To Newsletter</h3>
<div style="margin-top:10px;">
<label class="tit2">Name
<input type="text" name="name" value="" /></label>
<label class="tit2">Email Address
<input type="text" name="email" value="" /></label>
<input type="button" value="subscribe" class="btn_letter" onclick="sendData(document.enewsform)" />
<?php
require_once('recaptchalib.php');
$publickey = "your_public_key"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
</div>
</form>
订阅时事通讯
名称
电子邮件地址
要验证它,请在服务器端执行以下操作:
<?php
require_once('recaptchalib.php');
$privatekey = "your_private_key";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
} else {
// Your code here to handle a successful verification
}
?>
未解决此问题。通常在我们的新信中注册,而无需通过recaptcha。