Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将TCHA重新编译为自定义PHP表单_Php_Forms_Recaptcha - Fatal编程技术网

将TCHA重新编译为自定义PHP表单

将TCHA重新编译为自定义PHP表单,php,forms,recaptcha,Php,Forms,Recaptcha,我试图将recaptcha添加到我的定制PHP表单中,但对如何添加感到困惑。Recaptcha要求将recaptchalib.php添加到表单中,但如果我添加verify.php,则我的表单将不会处理,因为我使用php文件处理表单 <form method="POST" action="process.php" id="form-ok"> 这个问题有点令人困惑。我的问题是,我需要做什么来处理两个动作 你知道我该怎么做吗 Process.php <?php $redire

我试图将recaptcha添加到我的定制PHP表单中,但对如何添加感到困惑。Recaptcha要求将
recaptchalib.php
添加到表单中,但如果我添加
verify.php
,则我的表单将不会处理,因为我使用php文件处理表单

<form method="POST" action="process.php" id="form-ok">

这个问题有点令人困惑。我的问题是,我需要做什么来处理两个动作

你知道我该怎么做吗

Process.php

<?php

$redirectTo = '/thankyou.html';
$subject = 'New message from site'; // Email SUBJECT field

$receive = array(
    'example@example.com'
 );

 if($_POST['email_check'] == '') {

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

    $message = '<table width="100%" border="0" cellspacing="0" cellpadding="8" style="border:1px solid #f3f3f3">
                <tr>
                    <td colspan="3" height="30" style="font-size:20px"><strong>' . $subject . '</strong></td>
                </tr>
                <tr>
                    <td width="100" bgcolor="#f3f3f3"><strong>First Name: </strong></td>
                    <td width="14" height="30" bgcolor="#f3f3f3">&nbsp;</td>
                    <td width="305" bgcolor="#f3f3f3">' . $_POST ['first_name'] . '</td>
                </tr>
                <tr>
                    <td><strong>Last Name: </strong></td>
                     <td width="14" height="30">&nbsp;</td>
                    <td>' . $_POST ['last_name'] . '</td>
                </tr>
                <tr>
                    <td bgcolor="#f3f3f3"><strong>Email: </strong></td>
                     <td bgcolor="#f3f3f3" width="14" height="30">&nbsp;</td>
                    <td bgcolor="#f3f3f3">' . $_POST ['email'] . '</td>
                </tr>
                <tr>
                    <td><strong>Phone Number: </strong></td>
                     <td width="14" height="30">&nbsp;</td>
                    <td>' . $_POST ['phone'] . '</td>
                </tr>
                <tr>
                    <td bgcolor="#f3f3f3"><strong>Check: </strong></td>
                     <td bgcolor="#f3f3f3" width="14" height="30">&nbsp;</td>
                    <td bgcolor="#f3f3f3">';

                    foreach($_POST['role'] as $value)
                    {
                      $message.=$value.'<br>';
                    }
                    $message.='</td>
                </tr>
                <tr>
                    <td><strong>Message: </strong></td>
                     <td width="14" height="30">&nbsp;</td>
                    <td>' . $_POST ['message'] . '</td>
                </tr>
                <tr>
                    <td><strong>Referer:</strong></td>
                     <td width="14" height="30">&nbsp;</td>
                    <td>' . $_SERVER ['HTTP_REFERER'] . '</td>
                </tr>
                <tr>
                </table>';

        for ($i = 0; $i < count($receive); $i++){

        $to = $receive[$i];
        $headers  = 'MIME-Version: 1.0' . "\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
        $headers .=  'From: ' . $_POST['email'] . "\n" . 'Reply-To: ' . $_POST['email'] . "\n";

        mail($to, $subject, $message,$headers);

        }
        header('Location: '.$redirectTo);
    }
}
else{

header('Location:'.$_SERVER['HTTP_REFERER']); die();

}
?>

客户端(如何显示验证码图像)



服务器端 以下代码应放在process.php文件的顶部:

<?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
       die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
            "(reCAPTCHA said: " . $resp->error . ")");
     } else {
       // Your code here to handle a successful verification
     }
?>

客户端(如何显示验证码图像)



服务器端 以下代码应放在process.php文件的顶部:

<?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
       die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
            "(reCAPTCHA said: " . $resp->error . ")");
     } else {
       // Your code here to handle a successful verification
     }
?>

在目录中添加recaptchalib.php

您的PROCESS.PHP:

require_once "../recaptchalib.php"; // where you store recaptchalib.php
$secret = "6Le2g_sSxxxxxxxxxxxxxxxxxxxxxxxx"; //your secret key
$resp = null;
$error = null;
$reCaptcha = new ReCaptcha($secret);
if ($_POST["g-recaptcha-response"]) {
    $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]);
    }
if (isset($_POST['cmdlogin'])){
    if ($resp != null && $resp->success) {
        echo "<script>alert('Success Verifying Recaptcha!');</script>";
        echo "<meta http-equiv='refresh' content='0; url=login.php'>";
        exit();
        }

<form method="post" action="process.php">
.....other codes---
    <div class="g-recaptcha" data-
sitekey="6Le2g_sSxxxxxxxxxxxxxxxxxxxxxxxx">
    </div>
.....other codes---
</form>
require_once.。/recaptchalib.php”//您存储recaptchalib.php的位置
$secret=“6Le2g_ssxxxxxxxxxxxxxxxxxxxx”//你的秘密钥匙
$resp=null;
$error=null;
$reCaptcha=新的reCaptcha($secret);
如果($_POST[“g-recaptcha-response”]){
$resp=$reCaptcha->verifyResponse($\u服务器[“远程地址”],
$_POST[“g-recaptcha-response”];
}
如果(isset($\u POST['cmdlogin'])){
如果($resp!=null&&$resp->success){
echo“警报('Success verify Recaptcha!');”;
回声“;
退出();
}
……其他代码---
……其他代码---
完整教程,请点击此处:

在目录中添加recaptchalib.php

您的PROCESS.PHP:

require_once "../recaptchalib.php"; // where you store recaptchalib.php
$secret = "6Le2g_sSxxxxxxxxxxxxxxxxxxxxxxxx"; //your secret key
$resp = null;
$error = null;
$reCaptcha = new ReCaptcha($secret);
if ($_POST["g-recaptcha-response"]) {
    $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]);
    }
if (isset($_POST['cmdlogin'])){
    if ($resp != null && $resp->success) {
        echo "<script>alert('Success Verifying Recaptcha!');</script>";
        echo "<meta http-equiv='refresh' content='0; url=login.php'>";
        exit();
        }

<form method="post" action="process.php">
.....other codes---
    <div class="g-recaptcha" data-
sitekey="6Le2g_sSxxxxxxxxxxxxxxxxxxxxxxxx">
    </div>
.....other codes---
</form>
require_once.。/recaptchalib.php;//存储recaptchalib.php的位置
$secret=“6Le2g_ssxxxxxxxxxxxxxxxxxxxx”//您的密钥
$resp=null;
$error=null;
$reCaptcha=新的reCaptcha($secret);
如果($_POST[“g-recaptcha-response”]){
$resp=$reCaptcha->verifyResponse($\u服务器[“远程地址”],
$_POST[“g-recaptcha-response”];
}
如果(isset($\u POST['cmdlogin'])){
如果($resp!=null&&$resp->success){
echo“警报('Success verify Recaptcha!');”;
回声“;
退出();
}
……其他代码---
……其他代码---
完整教程,请点击此处:

它有什么让人困惑的地方?它非常清晰..在客户端和服务器中都添加recaptchalib.php。无论您将它命名为verify.php还是在您的case process.phpSo中都没有关系。我需要在verify.php中添加我的流程代码,对吗?好消息是,,,,,,您根本不需要verify.php!!!viola的意思是?那么这将如何验证recaptcha?可以吗请回答以下问题?您需要在
process.php
中包含ReCAPTCHA验证代码,并将其作为默认表单处理的一部分运行。这是一个单独的操作,因为ReCAPTCHA信息是作为表单的一部分提交的。这有什么让人困惑的吗?它非常清晰..在客户端和客户端中添加recaptchalib.php我需要在verify.php中添加我的流程代码,对吗?好消息是,,,,,,你根本不需要verify.php!!!viola!!意思是?那么这将如何验证recaptcha?你能回答下面的问题吗?你需要在
流程中包含recaptcha验证代码。php
,并将其作为默认表单处理的一部分运行。这是一个单独的操作,因为ReCAPTCHA信息是作为表单的一部分提交的。为什么需要verify.php?我想不起我的回答中有任何verify.php。现在工作正常!非常感谢!有一个问题,它在下一页“重新加载后”显示了错误的验证码消息我怎样才能让它生效呢?像这样一个简单的问题:你用的是什么版本的@RandykaYudhistira?不是USable@don我不用它。金国平用它。我只是回答他的问题question@KingoPing你需要AJAX。情况就不同了。那你为什么需要verify.php呢?我想不起我的回答中有任何verify.php。是的,现在工作很好!太棒了谢谢!一个问题,下一页“重新加载后”显示错误的验证码信息我怎样才能让它生效呢?像这样一个简单的问题:你用的是什么版本的@RandykaYudhistira?不是USable@don我不用它。金国平用它。我只是回答他的问题question@KingoPing这需要AJAX。情况不同,这是版本1.0或2.0?步骤4:验证用户响应-->我应该把它放在哪里?它的正在通过!无验证!请查看完整教程的链接,或者,单击此处>好吧,它使用1.0,但不使用2.0,因此我认为在实现中存在一些问题这是版本1.0或2.0?步骤4:用户响应验证--->我应该将其放置在何处?正在通过!无验证!请查看完整教程的链接,或者click here>嗯,它使用的是1.0,但不是2.0,所以我认为在实现上存在一些问题