• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic authentication system

#16
[eluser]jayrulez[/eluser]
thats quite simple if you have the login method in a different controller.

the setup should be something like this, this is not codeignitor standard but should give you an idea of what to do
Code:
if($this->request->isPost())
{
  $map['email'] = $_POST['email'];
  $map['pass'] = $_POST['pass'];

  $userDao = D('User');
  $user = $userDao->find($map);
  if($user)
  {
    //set cookies or sessions etc
    $this->redirect('private');
  }else{
    $error = 'email or password incorrect';
  }
  
}
$this->display();

and in your template file you might have

Code:
<div class="login">
  <present name="error"><div class="error">{$error}</div></present>
  &lt;form action="/login" method="post"&gt;
    <label>Email</label>&lt;input name="email" type="text" value="&lt;?php echo $_POST['email']; ?&gt;"/&gt;
    <br/>
    <label>Password</label>&lt;input name="pass" type="password" value=""/&gt;
    <br/>
    &lt;input type="submit" value="Login"/&gt;
  &lt;/form&gt;
</div>

now that way, even if login fails, the login page will be shown again and the email you entered previously will be in the input box for email


Messages In This Thread
Basic authentication system - by El Forum - 06-09-2009, 01:17 PM
Basic authentication system - by El Forum - 06-09-2009, 01:33 PM
Basic authentication system - by El Forum - 06-09-2009, 01:34 PM
Basic authentication system - by El Forum - 06-10-2009, 06:40 AM
Basic authentication system - by El Forum - 06-10-2009, 08:07 AM
Basic authentication system - by El Forum - 06-10-2009, 08:11 AM
Basic authentication system - by El Forum - 06-10-2009, 08:14 AM
Basic authentication system - by El Forum - 06-10-2009, 01:01 PM
Basic authentication system - by El Forum - 06-10-2009, 01:28 PM
Basic authentication system - by El Forum - 06-10-2009, 01:35 PM
Basic authentication system - by El Forum - 06-10-2009, 01:45 PM
Basic authentication system - by El Forum - 06-10-2009, 01:49 PM
Basic authentication system - by El Forum - 06-10-2009, 01:51 PM
Basic authentication system - by El Forum - 06-10-2009, 02:42 PM
Basic authentication system - by El Forum - 06-11-2009, 01:14 PM
Basic authentication system - by El Forum - 06-11-2009, 02:47 PM
Basic authentication system - by El Forum - 06-12-2009, 02:49 AM
Basic authentication system - by El Forum - 06-14-2009, 06:37 AM
Basic authentication system - by El Forum - 06-14-2009, 10:51 AM
Basic authentication system - by El Forum - 06-14-2009, 01:45 PM
Basic authentication system - by El Forum - 06-14-2009, 03:35 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.