Monday, January 31, 2011

Re: Error NewBe

try some like this


$someone = $this->User->find('first', array('conditions'=>array('User.username'=>$this->data['User']['username']));


should return an array.

2011/1/31 Joshua Muheim <psybear83@gmail.com>
You should check first whether your $someone array has a key "User"
before trying to access it:

http://php.net/manual/en/function.isset.php

This is a PHP issue, not a CakePHP one. :-)

On Mon, Jan 31, 2011 at 9:07 AM, sadeepap <sadeepa.palliyaguru@gmail.com> wrote:
> Hi ,
>
> I am a new comer to Cake and has the following error message in one of
> my codes.
>
> Notice (8): Undefined index: User [APP\controllers
> \users_controller.php, line 28]
>
> Code at users_controller.php
>
> <?php
> class UsersController extends AppController
> {
>        var $name='Users';
>    var $uses = array('User');
>
>        function index(){
>
>        }
>
>        function register(){
>
>
>        }
>
>        function uploadcv(){
>
>
>        }
>
>        function login(){
>
>                $this->set('error',false);
>
>                if(!empty($this->data))
>                {
>                        // $someone=$this->User->findByUsername('alpha');
>                        $someone=$this->User->findByUsername($this->data['User']
> ['username']);
>                 if(!empty($someone['User']['password']) && $someone['User']
> ['password'] == $this->data['User']['password'])
> {
>                                $this->Session->write('User', $someone['User']);
>                                $this->redirect('/clients');
>                 }
>                 else
>                 {
>                                                $this->set('error', true);
>                 }
>
>
>
>
>                }
>        }
>
>        function logout(){
>
>
>        }
> }
> ?>
>
> Can someone please help me ?
>
> --
> Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
>

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php



--
Taffarel de Lima Oliveira (Taffarelo3)

Desenvolvedor Web

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: