Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.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
这个代码对吗?(使用catpcha的PHP POST方法)_Php_Captcha - Fatal编程技术网

这个代码对吗?(使用catpcha的PHP POST方法)

这个代码对吗?(使用catpcha的PHP POST方法),php,captcha,Php,Captcha,我是一个非常新手的php开发人员;我决定创建一个用户登录系统。 对于系统,我想使用captcha系统。我的问题是,当我点击“发送”按钮时,我无法发送表单的数据(两个文本框:用户名和邮件地址)。 为了让它发挥作用;我创建了一个接收表单数据的方法,该数据的发送方式如下:method_name($POST[“username”],$POST[“mail”]); 我想知道这是不是正确的,或者它会有一些安全问题或者其他问题 谢谢 对不起,我的英语…不好。 这是索引页 <?php requir

我是一个非常新手的php开发人员;我决定创建一个用户登录系统。 对于系统,我想使用captcha系统。我的问题是,当我点击“发送”按钮时,我无法发送表单的数据(两个文本框:用户名和邮件地址)。 为了让它发挥作用;我创建了一个接收表单数据的方法,该数据的发送方式如下:method_name($POST[“username”],$POST[“mail”]); 我想知道这是不是正确的,或者它会有一些安全问题或者其他问题

谢谢

对不起,我的英语…不好。 这是索引页

    <?php
require_once('recaptchalib.php');
require_once('home.php');

$publickey = "foo";
$privatekey = "bar";

$error = null;

if ($_POST['action'] == "register") {
    $re_ip = $_SERVER["REMOTE_ADDR"];
    $re_challenge = $_POST["recaptcha_challenge_field"];
    $re_response = $_POST["recaptcha_response_field"];

    $resp = recaptcha_check_answer($privatekey, $re_ip, $re_challenge, $re_response);

    if ($resp->is_valid) {
        // procesar registro
            hello($_POST["username"],$_POST["usermail"]);
        exit;
    } else {
        $error = $resp->error;
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>reCAPTCHA Demo</title>
<style type="text/css">

body {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #333;
    line-height: 18px;
}
.casilla {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 11px;
    color: #333;
    padding: 2px 4px;
    width: 298px;
    margin-left: 3px;
}
h3 {
    color: #03C;
    font-size: 16px;
}

</style>
<link rel="stylesheet" href="stylesheets/css3buttons.css" media="screen"/>
</head>
<body>
<h3>Registro</h3>
<form method="post">
    <label for="username">Usuario</label><br />
    <input name="username" type="text" class="casilla" id="username" /><br />
    <label for="usermail">Email</label><br />
    <input name="usermail" type="text" class="casilla" id="usermail" /><br />
    <label for="usercheck">Verificaci&oacute;n</label><br />
    <?php echo recaptcha_get_html($publickey, $error); ?>
    <input type="hidden" name="action" value="register" />
    <button type="submit" name="btsend" value="Enviar">Iniciar Sesión</button>
</form>
</body>
</html>
**and this is other page**

    <!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        function hello($var1,$var2)
        {
            $mailFilter = "^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$";
            echo"HELLO WORLD\n".$var1."---".$var2;
            if (preg_match($mailFilter, $var2)) {
            echo "A match was found.";
            } else {
                echo "correo valido.";
            }
        }
        ?>
    </body>
</html>

雷帕查演示
身体{
字体系列:“投石机MS”,Arial,Helvetica,无衬线;
字体大小:12px;
颜色:#333;
线高:18px;
}
卡西拉先生{
字体系列:“投石机MS”,Arial,Helvetica,无衬线;
字体大小:11px;
颜色:#333;
填充物:2px4px;
宽度:298px;
左边距:3倍;
}
h3{
颜色:#03C;
字体大小:16px;
}
登记处
乌萨里奥

电子邮件

验证和验证;n
伊尼西亚·塞西翁 **这是另一页**
如果表单无法发送,那么我将假定表单声明缺少
操作=
URL。通常你会写:

 <form method="POST" action="index.php">

如果表单无法发送,那么我将假设因为表单声明缺少
action=
URL。通常你会写:

 <form method="POST" action="index.php">

请不要发布您的私钥。这不是个好主意。是的,你是对的。我不会再这样做了。电邮team@stackoverflow.com如果您需要反转编辑历史记录,但由于您的私钥已被泄露,您最好的选择可能是获取新的私钥。请不要发布您的私钥。这不是个好主意。是的,你是对的。我不会再这样做了。电邮team@stackoverflow.com如果您需要反转编辑历史记录,但由于您的私钥已被泄露,您最好的选择可能是获取新的私钥。正如您所提到的,我已经尝试过,但我认为错误在这里:if($resp->is_valid){//当我点击发送按钮时,代码进入这里。//如果我不调用我的函数hello(…)代码什么都不做hello($\u POST[“username”],$\u POST[“usermail”]);exit;}否则{$error=$resp->error;}那么,你会收到任何错误消息吗?否则请尝试
如果($resp&&&$resp->是否有效){
相反。任何错误消息都会显示出来。我尝试了if($resp&&$resp->is_valid){…并且我看到url更改为localhost/home.php。因此,如果代码出现在另一个文件:home.php,但什么也不做。看到错误非常明显,我非常失望。当我尝试按照您提到的那样做时,我放了:print$POST[“ID”],当它应该是:print$_POST[“ID”];现在一切都好了。我会更加注意我代码的语法,我让你浪费了时间,很抱歉。非常感谢你所做的一切!URL是如何更改的?我对你的示例感到困惑。也许你应该解释文件部分。或者这实际上是两个文件?那么
如果($\u POST…
检查接收脚本中的blongs。我已经按照您提到的那样尝试过了,但是我认为错误在这里:如果($resp->is\u valid){//当我单击发送按钮时,代码输入这里。//如果我不调用我的函数hello(…)代码不做任何事情hello($\u POST[“username”],$\u POST[“usermail”]));exit;}else{$error=$resp->error;}好吧,你有没有收到任何错误消息?如果($resp&&$resp->有效,请尝试
if{
。任何错误消息都会显示出来。我尝试了($resp&&$resp->有效){…我看到url更改为localhost/home.php。因此,如果它指向另一个文件:home.php,但什么也不做,那么代码将非常令人失望,因为错误非常明显。当我尝试执行您提到的操作时,我将:print$POST[“ID”],当它应该是:print$_POST[“ID”];现在一切都好了。我会更加注意我代码的语法,我让你失去了时间,我很抱歉。非常感谢你所做的一切!URL是如何更改的?我对你的示例感到困惑。也许你应该解释文件部分。或者这两个文件是真的吗?然后,
if($\u POST…
检查接收脚本中的blongs。