Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.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
CakePHP表单不会作为Post方法提交,并且不会返回任何数据_Php_Cakephp - Fatal编程技术网

CakePHP表单不会作为Post方法提交,并且不会返回任何数据

CakePHP表单不会作为Post方法提交,并且不会返回任何数据,php,cakephp,Php,Cakephp,我正在Cake中创建身份验证。我在register.ctp中有以下代码 <?php echo $this->Form->create('User'); ?> <div class="col-sm-12"> <div class="form-group"> <?php echo

我正在Cake中创建身份验证。我在register.ctp中有以下代码

<?php echo $this->Form->create('User'); ?>
                <div class="col-sm-12">
                    <div class="form-group">
                        <?php
                        echo $this->Form->input('email', array('class' => 'form-control'));
                        echo $this->Form->input('first_name', array('class' => 'form-control'));
                        echo $this->Form->input('last_name', array('class' => 'form-control'));
                        echo $this->Form->input('phone', array('class' => 'form-control'));
                        echo $this->Form->input('password', array('class' => 'form-control'));
                        echo $this->Form->input('password_confirmation', array('type'=>'password', 'class' => 'form-control'));
                        echo $this->Recaptcha->show(array('theme' => 'white'));
                        echo $this->Recaptcha->error();
                        ?>
                        <p>
                        <?php
                              echo $this->Form->end(array('label' => 'Register',  'class' =>"btn btn-lg btn-block ".  $this->Buttons->color($account['Config']['theme'])));
                        ?>
                    </p>
现在,当我提交表单时,它将输入字段作为GET方法附加到URL的末尾,并且没有数据传递给控制器。以下是呈现的html代码:

<form action="/users/register" id="UserRegisterForm" method="post" accept-charset="utf-8">
<div style="display:none;">
    <input type="hidden" name="_method" value="POST" />
</div>
<div class="col-sm-12">
    <div class="form-group">
        <div class="input email required">
            <label for="UserEmail">Email</label>
            <input name="data[User][email]" class="form-control" maxlength="255" type="email" id="UserEmail" required="required" />
        </div>
        <div class="input text required">
            <label for="UserFirstName">First Name</label>
            <input name="data[User][first_name]" class="form-control" maxlength="100" type="text" id="UserFirstName" required="required" />
        </div>
        <div class="input text required">
            <label for="UserLastName">Last Name</label>
            <input name="data[User][last_name]" class="form-control" maxlength="100" type="text" id="UserLastName" required="required" />
        </div>
        <div class="input tel required">
            <label for="UserPhone">Phone</label>
            <input name="data[User][phone]" class="form-control" maxlength="20" type="tel" id="UserPhone" required="required" />
        </div>
        <div class="input password required">
            <label for="UserPassword">Password</label>
            <input name="data[User][password]" class="form-control" type="password" id="UserPassword" required="required" />
        </div>
        <div class="input password required">
            <label for="UserPasswordConfirmation">Password Confirmation</label>
            <input name="data[User][password_confirmation]" class="form-control" type="password" id="UserPasswordConfirmation" required="required" />
        </div>
        <script>
        var RecaptchaOptions = {
            "theme": "white"
        };
        </script>
        <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LcDOecSAAAAAPgyYLxxtad0urkh9f-AgJ1IYLDE"></script>

        <noscript>
            <iframe src="http://www.google.com/recaptcha/api/noscript?k=6LcDOecSAAAAAPgyYLxxtad0urkh9f-AgJ1IYLDE" height="300" width="500" frameborder="0"></iframe>
            <br/>
            <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
            <input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
        </noscript>
        <p>
            <div class="submit">
                <input class="btn btn-lg btn-block btn-warning" type="submit" value="Register" />
            </div>

电子邮件
名字
姓
电话
暗语
密码确认
var RecaptchaOptions={
“主题”:“白色”
};

我似乎找不到问题。也许,这里的某个人会知道答案

谢谢,
格雷格

问题可能在于验证码的使用。我不知道这是如何实现的,但它可能会影响表单。试着把它取下来,看看是否有用

此外,您可能应该在同一个div中启动表单,如下所示:

<div class="col-sm-12">
    <div class="form-group">
        <?php
        // Start the form
        echo $this->Form->create('User');

        echo $this->Form->input('email', array('class' => 'form-control'));
        echo $this->Form->input('first_name', array('class' => 'form-control'));
        echo $this->Form->input('last_name', array('class' => 'form-control'));
        echo $this->Form->input('phone', array('class' => 'form-control'));
        echo $this->Form->input('password', array('class' => 'form-control'));
        echo $this->Form->input('password_confirmation', array('type'=>'password', 'class' => 'form-control'));
        echo $this->Recaptcha->show(array('theme' => 'white'));
        echo $this->Recaptcha->error();
        ?>

        <p>
            <?php
                // End the form
                echo $this->Form->end(array('label' => 'Register',  'class' =>"btn btn-lg btn-block ".  $this->Buttons->color($account['Config']['theme'])));
            ?>
        </p>
    </div>
</div>



谢谢,但我已经试过了。我尝试了各种方法,但都没有成功。
现在当我提交表单时,它会将输入字段附加到URL的末尾
一个常见的原因是嵌套的表单标记。表单标记中不能有表单标记;i、 e.很可能您没有提交此表格

<div class="col-sm-12">
    <div class="form-group">
        <?php
        // Start the form
        echo $this->Form->create('User');

        echo $this->Form->input('email', array('class' => 'form-control'));
        echo $this->Form->input('first_name', array('class' => 'form-control'));
        echo $this->Form->input('last_name', array('class' => 'form-control'));
        echo $this->Form->input('phone', array('class' => 'form-control'));
        echo $this->Form->input('password', array('class' => 'form-control'));
        echo $this->Form->input('password_confirmation', array('type'=>'password', 'class' => 'form-control'));
        echo $this->Recaptcha->show(array('theme' => 'white'));
        echo $this->Recaptcha->error();
        ?>

        <p>
            <?php
                // End the form
                echo $this->Form->end(array('label' => 'Register',  'class' =>"btn btn-lg btn-block ".  $this->Buttons->color($account['Config']['theme'])));
            ?>
        </p>
    </div>
</div>