Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Entity;
- class UserLoginForm extends \DOMForm\Form
- {
- public function Initialize()
- {
- $this->AddField(
- new \DOMForm\Fields\Input('text','username','Username',true) ,
- new \DOMForm\Fields\Password('password','Password',true) ,
- new \DOMForm\Fields\Submit('btnLogin', 'Process Login')
- );
- }
- public function Process()
- {
- $u = new User;
- $u->type = $this->smarty_params['login_type']?:'member';
- $u->username = $_POST['username'];
- $u->password = $_POST['password'];
- $st = $u->Select();
- if ( $st && $st->RowCount() > 0 )
- {
- $this->RemoveCache();
- $user = $st->Fetch( \DAO\FETCH_OBJ );
- $_SESSION['idUser'] = $user->id;
- $_SESSION['username'] = $user->username;
- $_SESSION['fullname'] = $user->fullname;
- if ( isset($_COOKIE['login_redirect']) )
- {
- $url = parse_url($_COOKIE['login_redirect']);
- unset($_COOKIE['login_redirect']);
- header('location: '. $url['path'].($url['query']?'?'.$url['query']:''));
- exit;
- }
- return true;
- } else {
- $this->Error('Invalid Login');
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement