简体   繁体   English

如何将CodeIgniter的/ TankAuth的注册表和登录表单放在同一页面上?

[英]How do I put CodeIgniter's/TankAuth's register and login forms on the same page?

I'm using CodeIgniter for my php framework and TankAuth for my authorization/registration. 我正在为我的php框架使用CodeIgniter,为我的授权/注册使用TankAuth。 By default, TankAuth places the registration and login forms on separate pages. 默认情况下,TankAuth将注册和登录表单放在不同的页面上。 I would like to place the log-in form in the navigation bar that occurs on every page. 我想将登录表单放在每个页面上的导航栏中。 There is also a sign-up page that will have the registration form occurring simultaneously as the log-in form (located in the navbar). 还有一个注册页面,其注册表单同时作为登录表单(位于导航栏中)发生。

I am currently using this in controllers/signup.php .index()... 我目前在controllers / signup.php .index()中使用它...

            $this -> load -> view('templates/header');
            $this -> login();
            $this -> register();
            $this -> load -> view('templates/footer');

This displays correctly but I have two issues: 这显示正确,但我有两个问题:

1 Will I have to redefine TankAuth's methods in every controller that will have the log-in form? 1我是否必须在每个具有登录形式的控制器中重新定义TankAuth的方法?

2 When I try to register it tells me that the log-in form should be filled out as well. 2当我尝试注册时,它告诉我应该填写登录表单。 That's obviously a catch-22. 这显然是一个抓地力22。

(I apologize if this is too domain specific or vague; I hope it makes sense to those who have worked with the framework.) (如果这个域太具体或含糊不清,我很抱歉;我希望那些使用过该框架的人有意义。)

我不确定这是否仍然是一个问题,但如果您真的想这样做,您可以将一个视图作为IFRAME包含在另一个视图中而不会出现任何问题。

I'm not sure what you are trying to achieve by just combining login & register views, they were not designed to work together, so you definetly need to do some modifications to the base tank auth structure. 我不确定你想通过组合登录和注册视图来实现什么,它们不是为了协同工作而设计的,所以你肯定需要对基础槽认证结构进行一些修改。

This really shouldn't be a confusing issue as its just a problem you created for yourself by combining two very similar forms. 这真的不应该是一个令人困惑的问题,因为它只是你通过组合两个非常相似的形式为自己创建的一个问题。

To simply walk through this, (and I don't know what code changes if any you made) first you must create your own login (html), set the form action="/auth/login" . 要简单地完成这个,(并且我不知道你做了什么代码改变)首先你必须创建自己的登录(html),设置表单action="/auth/login"

The login will submit, IF it is all clear the user is logged in and you handle it like that, HOWEVER if they fail to login, they will be brought to a single page login (default/or modified) where they can re-try again. 登录将提交, 如果一切都清楚,用户已登录并且您处理它, 但是如果他们无法登录,他们将被带到单页登录(默认/或修改)他们可以重新尝试再次。

The same should follow for registration, set the form action="/auth/register" and let it submit against tank auth controller. 注册时也应如此,设置表单action="/auth/register"并让它提交坦克auth控制器。 Again, if registration is successfull, they will just get shuttled through wherever, otherwise brought to a single registration page. 同样,如果注册成功,他们将在任何地方穿梭,否则将被带到一个注册页面。

Use the original login and registration views as a start to what you need to change / update. 使用原始登录注册视图作为更改/更新所需内容的开始。

Tank Auth is really a plugin, that you need to modify to suit your needs, its code is clean and clear, so just go through it so you understand what happens at login, what happens at registration, activation etc, otherwise mashing things together will not get you anywhere. Tank Auth是一个真正的插件,你需要修改以满足你的需求,它的代码是干净清晰的,所以只需要通过它,你就可以了解登录时会发生什么,注册时会发生什么,激活等等,否则会将事情混合在一起不会让你到任何地方。 In my personal experience with the library, I have ALWAYS modified it beyond the initial setup, just because it is simple to do. 根据我对图书馆的个人经验,我总是将其修改为初始设置,因为它很简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM