我已经使用有效的PHP邮件代码设置了电子邮件系统,现在我希望尝试将Google reCAPTCHA插入表单和PHP邮件中。当我刚接触PHP时,如何验证用户的响应?
我试图遵循有关验证响应的google文档,但是对于PHP新手来说,这都不是很清楚。我尝试过在线查找get_response代码,但似乎没有任何效果。以下是我的sendmail.php的代码。
<?php
$to='jamie.cooke94@gmail.com';
$subject="Enquiry";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html; charset=utf-8" . "\r\n";
$headers .= "From:".$_REQUEST['email']."\r\n";
$message='<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" align="center" ><b><font color="#FFFFFF">Your Form Details</font></b></td>
</tr>
<tr bgcolor="#FFFFFF">
<td><b>Dear User,</b></td>
</tr>
<tr bgcolor="#FFFFFF" align="left" >
<td>Information Details</td>
</tr>
<tr bgcolor="#FFFFFF" align="left">
<td>
<b>First Name:</b> '.$_REQUEST['name'].'<br>
<b>Email:</b> '.$_REQUEST['email'].'<br>
<b>Phone:</b> '.$_REQUEST['phone'].'<br>
<b>Messsage:</b> '.$_REQUEST['message'].'<br>
</tr>
<tr>
<td> </td>
</tr>
<tr> </tr>
</table></td>
</tr>
</table>';
if(mail($to, $subject, $message, $headers,'-f noreply@example.com'))
{
echo "<script>window.location='index.html?val=2'</script>";
}
else
{
echo "<script>window.location='index.html?val=3'</script>";
}
?>