Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- public function indexAction()
- {
- // Zend form
- $loginForm = new My_Form_Login($_POST);
- // Post/get submit values
- $user = $this->getRequest()->getParam('username');
- $pass = $this->getRequest()->getParam('password');
- // Check if the form valid
- if (isset($user) && isset($pass) ) {
- // Database connection
- $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'production');
- $db = Zend_Db::factory($config->resources->db);
- $this->db = $db;
- // Database coonnect >> Tables > Field1 , Field 2
- $adapter = new Zend_Auth_Adapter_DbTable(
- $db,
- 'clients',
- 'email',
- 'nickname'
- );
- // Search username password
- $adapter->setIdentity($user);
- $adapter->setCredential($pass);
- // Submit search
- $result = $adapter->authenticate();
- // login success fail route
- if ($result->isValid()) {
- /**
- * Successfully loged in
- *
- */
- $rows = new Application_Model_Clients();
- $dbsession = $rows->give_sessions($user);
- $mysession = new Zend_Session_Namespace('mysession');
- $mysession->rows = $dbsession;
- if ($mysession->rows['clienttype']=='lezer') {
- $this->_redirect('/login/surferaccount');
- } else {
- $this->_redirect('/login/myaccount');
- }
- } else {
- echo 'Invalid username/password. Please try again with valid information.';
- }
- }
- echo $loginForm;
- }
Add Comment
Please, Sign In to add comment