In cakephp 2+ filenames are CamelCased so rename
> app/controller/users_controller.php
> to
> app/Controller/UsersController.php
>
> app/app_controller.php
> to
> app/Controller/AppController.php
also:
> app/View/users/login.ctp
to
app/View/Users/login.ctp
etc..
Andras Kende
http://www,kende.com
On Dec 7, 2013, at 4:17 AM, Rajesh Vishnani <vishnani.2007@gmail.com> wrote:
> I am simply doing login and registration of users in cake php, here is my file structure!
>
> app/controller/users_controller.php
>
> <?
> php
>
> class UsersController extends AppController {
>
>
>
> public function beforeFilter() {
>
> parent
> ::beforeFilter();
>
> $this
> ->Auth->allow('add');
>
>
> }
>
>
> public function add() {
>
>
> if(!empty($this->data)) {
>
> $this
> ->User->create();
>
>
> if($this->User->save($this->data)) {
>
> $this
> ->Session->SetFlash('User Created!');
>
> $this
> ->redirect(array('action'=>'login'));
>
>
> }
>
>
> else {
>
> $this
> ->Session->SetFlash('Please correct the errors!');
>
>
> }
>
>
> }
>
>
> }
>
>
> public function login() {
>
>
>
> }
>
>
> public function logout() {
>
> $this
> ->redirect($this->Auth->logout());
>
>
> }
>
>
> }
> ?>
> app/app_controller.php
>
> <?
> php
>
> class AppController extends Controller {
>
>
> public $components = array(
>
>
> 'Auth' => array(
>
>
> 'authorize'=>'controller'
>
>
> ),
>
>
> 'Session'
>
>
> );
>
>
> public function isAuthorized() {
>
>
> return true;
>
>
> }
>
>
> }
> ?>
> app/View/users/login.ctp
>
> <?
> php
> echo $this
> ->Form->create(array('action'=>'login'));
>
> echo $this
> ->Form->inputs(array('legend'=>'Login','username','password'));
>
> echo $this
> ->Form->end('Login');
> ?>
> app/View/users/add.ctp
>
> <?
> php
> echo $this
> ->Form->create();
>
> echo $this
> ->Form->inputs(array(
>
>
> 'legends' => 'Signup',
>
>
> 'username',
>
>
> 'password'));
>
> echo $this
> ->Form->end('Submit');
> ?>
> and i am browsing below URL
>
> www.abc.com/../cakephp/users/add
>
> i get below erros
>
> Error: UsersController could not be found.
>
> Error: Create the class UsersController below in file: app/Controller/UsersController.php
>
> <?
> php
>
> class UsersController extends AppController {
>
>
>
> }
> Notice: If you want to customize this error message, create app/View/Errors/missing_controller.ctp
>
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
Sunday, December 8, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment