构建CakePHP注册页面 [英] Structuring a CakePHP Registration Page

查看:167
本文介绍了构建CakePHP注册页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,我希望用户注册到特定的组。为了访问该组,您需要知道其组织ID和组织密码。



我正在尝试创建一个表单,允许我验证组ID和密码存在并且是正确的,然后创建一个新的用户。我想要验证用户表单中的所有字段,并让他们自动幻影打印错误,如果它们不工作。



讽刺的是,当我烘烤我的应用程序它会创建成功显示错误消息的表单。因为某些原因,我无法通过我的自定义表单打印任何验证错误。



我这样做的方式是:

 < div class =full center> 
<
echo $ this-> Session-> flash();
echo $ this-> Session-> flash('auth');
?>
< h3>组织ID /注册代码< / h3>
<?php
echo $ this-> Form-> create('User',array('action'=>'register_user'));
echo $ this-> Form-> input('Organization.id',array('type'=>'text','label'=>'Organization ID'));
echo $ this-> Form-> input('Organization.registration_code',array('label'=>'Organization Registration Code')); ?>
< h3>用户帐户信息< / h3>
<?php
echo $ this-> Form-> input('User.email');
echo $ this-> Form-> input('User.password',array('value'=>''));
echo $ this-> Form-> input('User.name');
echo $ this-> Form-> input('User.xxxx');
echo $ this-> Form-> input('User.xxxx');
echo $ this-> Form-> input('User.xxxx');
echo $ this-> Form-> input('User.xxxx');
?>
< div>< input type =checkboxname =data [tos] [agree]>我同意服务条款。< / div>
< div>< input type =checkboxname =data [pp] [agree]>我同意隐私政策。< / div>
<?php echo $ this-> Form-> end(__('Join my Organization',true));?>
< / div>

但没有任何工作!请让我知道这是否是正确的方式来构建这种类型的注册表单,以及如何让我的错误显示!!!



另外,我需要一个类似的注册页面,我在使用用户的信息和组织的信息,然后创建组织和用户,并将用户添加到组织。如何结构化?



谢谢!

解决方案

 < div class =full center> 
<
if($ session-> check('Message.flash'))
{
echo $ this-> Session-> flash();
echo $ this-> Session-> flash('auth');
}
?>
< h3>组织ID /注册代码< / h3>
<?php
echo $ this-> Form-> create('User',array('action'=>'register_user'));
echo $ this-> Form-> input('Organization.id',array('type'=>'text','label'=>'Organization ID'));
echo $ this-> Form-> input('Organization.registration_code',array('label'=>'Organization Registration Code')); ?>
< h3>用户帐户信息< / h3>
<?php
echo $ this-> Form-> input('User.email');
echo $ this-> Form-> input('User.password',array('value'=>''));
echo $ this-> Form-> input('User.name');
echo $ this-> Form-> input('User.xxxx');
echo $ this-> Form-> input('User.xxxx');
echo $ this-> Form-> input('User.xxxx');
echo $ this-> Form-> input('User.xxxx');
?>
< div>< input type =checkboxname =data [tos] [agree]>我同意服务条款。< / div>
< div>< input type =checkboxname =data [pp] [agree]>我同意隐私政策。< / div>
<?php echo $ this-> Form-> end(__('Join my Organization',true));?>


I have a site where I want users to register to particular groups. In order to access that group, you need to know their Organization ID and Organization Password.

I am trying to create a form which will allow me to validate that the Group ID and Password exist and are correct, then create a new User. I want to Validate all of the fields in the User form and have them auto-magically print errors if they do not work.

Ironically, when I "baked" my application it creates forms which successfully show error message. For SOME reason, though, I cannot get it to print out any validation errors with my custom form.

The way I am doing this is:

<div class="full center">
        <?
            echo $this->Session->flash();
            echo $this->Session->flash('auth');
        ?>
        <h3>Organization ID / Registration Code</h3>
        <?php 
            echo $this->Form->create('User', array('action'=>'register_user'));
            echo $this->Form->input('Organization.id', array('type'=>'text', 'label' => 'Organization ID'));
            echo $this->Form->input('Organization.registration_code', array('label' => 'Organization Registration Code')); ?>
        <h3>User Account Information </h3>
        <?php
            echo $this->Form->input('User.email');
            echo $this->Form->input('User.password', array('value'=>''));
            echo $this->Form->input('User.name');
            echo $this->Form->input('User.xxxx');
            echo $this->Form->input('User.xxxx');
            echo $this->Form->input('User.xxxx');
            echo $this->Form->input('User.xxxx');
        ?>
        <div><input type="checkbox" name="data[tos][agree]"> I agree to the Terms of Service.</div>
        <div><input type="checkbox" name="data[pp][agree]"> I agree to the Privacy Policy.</div>
        <?php echo $this->Form->end(__('Join my Organization', true));?>
</div>

But nothing is working! Please let me know if this is the correct way to structure this type of registration form and how to get my errors showing up!!!

Also, I'll need a similar registration page where I am taking in both a User's information and an Organization's information, then create the organization and the user and add the user to the Organization. How would that be structured?

Thanks!

解决方案

<div class="full center">
    <?
        if($session->check('Message.flash')) 
      { 
        echo $this->Session->flash();
        echo $this->Session->flash('auth');
       }
    ?>
    <h3>Organization ID / Registration Code</h3>
    <?php 
        echo $this->Form->create('User', array('action'=>'register_user'));
        echo $this->Form->input('Organization.id', array('type'=>'text', 'label' => 'Organization ID'));
        echo $this->Form->input('Organization.registration_code', array('label' => 'Organization Registration Code')); ?>
    <h3>User Account Information </h3>
    <?php
        echo $this->Form->input('User.email');
        echo $this->Form->input('User.password', array('value'=>''));
        echo $this->Form->input('User.name');
        echo $this->Form->input('User.xxxx');
        echo $this->Form->input('User.xxxx');
        echo $this->Form->input('User.xxxx');
        echo $this->Form->input('User.xxxx');
    ?>
    <div><input type="checkbox" name="data[tos][agree]"> I agree to the Terms of Service.</div>
    <div><input type="checkbox" name="data[pp][agree]"> I agree to the Privacy Policy.</div>
    <?php echo $this->Form->end(__('Join my Organization', true));?>

这篇关于构建CakePHP注册页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆