Okay, I found this example here:
http://www.jamesfairhurst.co.uk/posts/view/creating_an_admin_section_with_cakephp/
which talks me through how to create an admin area.  It's actually
pretty simple, starting by just uncommenting the admin routing line
in /app/config/core.php.

However, when I'm logging into the admin area, it's erroring, saying:

Notice (8): Undefined index:  User [APP\controllers
\users_controller.php, line 10]


The users_controller.php file looks like this:

<?php
class UsersController extends AppController {
        var $name = 'Users';
        var $helpers = array('Html', 'Form');

        function login() {
                // if the form was submitted
                if(!empty($this->data)) {
                        // find the user in the database
                        $dbuser = 
$this->User->findByUsername($this->data['User']
['username']);
                        // if found and passwords match
                        if(!empty($dbuser) && ($dbuser['User']['password'] == 
md5($this-
>data['User']['password']))) {
                                // write the username to a session
                                $this->Session->write('User', $dbuser);
                                // save the login time
                                $dbuser['User']['last_login'] = date("Y-m-d 
H:i:s");
                                $this->User->save($dbuser);
                                // redirect the user
                                $this->Session->setFlash('You have successfully 
logged in.');
                                $this->redirect('/admin/posts/');
                        } else {
                                $this->set('error', 'Either your username or 
password is
incorrect.');
                        }
                }
        }

        function logout() {
                // delete the user session
                $this->Session->delete('User');
                // redirect to posts index page
                $this->Session->setFlash('You have successfully logged out.');
                $this->redirect('/posts/');
        }
}
?>



The line which is erroring is:

$dbuser = $this->User->findByUsername($this->data['User']
['username']);


Can anyone see why this is happening, and how to solve it?

Thanks all...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to