Instead redirecting, i get this.. Any Ideas?

login.thml:
<?php
if ($error)
{
  e('Invalid Login.');
}
?>
<p>
 Please log in.
</p>

<?php echo $html->form('/users/login') ?>
<label>Username:</label>
<?php echo $html->input('User/username', array) ?>
<label>Password:</label>
<?php echo $html->password('User/password', array) ?>
<?php echo $html->submit('login') ?>

</form>
<?php echo $html->link('register', '/users/register') ?>


users_controller.php:
<?php
class UsersController extends AppController
{
  function register()
  {
    $this->set('username_error', 'Username must be between 6 and 40
characters.');
    if (!empty($this->data))
    {
      if ($this->User->validates($this->data))
      {
               if ($this->User->findByUsername($this->data['User']
['username']))
               {
                 $this->User->invalidate('username');
                 $this->set('username_error', 'User already exists.');
               } else {
                 $this->data['User']['password'] = md5($this-
>data['User']['password']);
          $this->User->save($this->data);
          $this->Session->write('user', $this->data['User']
['username']);
          $this->redirect('/users/index');
        }
      } else {
        $this->validateErrors($this->User);
      }
    }
  }
  function knownusers()
  {
    $this->set('knownusers', $this->User->findAll(null, array('id',
'username',
'first_name', 'last_name', 'last_login'), 'id DESC'));
  }
  function login()
  {
    $this->set('error', false);
    if ($this->data)
    {
      $results = $this->User->findByUsername($this->data['User']
['username']);
      if ($results && $results['User']['password'] ==
md5($this->data['User']['password']))
      {
        $this->Session->write('user', $this->data['User']
['username']);
        $this->Session->write('last_login', $results['User']
['last_login']);
        $results['User']['last_login'] = date("Y-m-d H:i:s");
        $this->User->save($results);
        $this->redirect('/users/index');
      } else {
      $this->set('error', true);
      }
    }
  }
  function logout()
  {
    $this->Session->delete('user');
    $this->redirect('/users/login');
  }
  function index()
  {
    $username = $this->Session->read('user');
    if ($username)
    {
      $results = $this->User->findByUsername($username);
      $this->set('User', $results['User']);
      $this->set('last_login', $this->Session->read('last_login'));
    } else {
      $this->redirect('/users/login');
    }
  }
}
?>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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