Thank you Marco pivetta

The values are getting inserted into the database , but still i dont know
why this error occuring

//complete controller


<?php

class SignupController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $auth = Zend_Auth::getInstance();
                if($auth->hasIdentity()){
                        $this->view->identity = $auth->getIdentity();
                        }
    }

    public function createAction()
    {
        $userForm = new Form_SignUpForm();
                if($this->_request->isPost())
                {
                        if($userForm->isValid($_POST))
                        {
                                $userModel = new Model_SignUpForm();
                                $userModel->createUser(
                                        $userForm->getValue('fullname'),
                                        $userForm->getValue('username'),
                                        $userForm->getValue('password'),
                                        $userForm->getValue('email'),
                                        $userForm->getValue('dob'),
                                        $userForm->getValue('gender')
                                );
                                return $this->_forward('list');
                        }
                }               
                                
                $userForm->setAction('/LC_Case/public/signup/create');
                $this->view->form = $userForm;
    }
        
        public function loginAction()
        {
                $userForm = new Form_SignUpForm();
                $userForm->setAction('/LC_Case/public/signup/login');
                $userForm->removeElement('fullname');
                $userForm->removeElement('username');
                $userForm->removeElement('dob');
                $userForm->removeElement('gender');
                $this->view->form = $userForm;
                
                if($this->_request->isPost() && $userForm->isValid($_POST)){
                        $data = $userForm->getValues();
                        //set up the authrisation adapter
                        //get the default database adapter
                        $db = Zend_Db_Table::getDefaultAdapter();
                        //creationg auth adapter
                        $authAdapter = new
Zend_Auth_Adapter_DbTable($db,'users','password','email');
                        //setting username and password
                        $authAdapter->setIdentity($data['username']);
                        $authAdapter->setCredential(md5($data['password']));
                        //Authentication
                        $result = $authAdapter->authenticate();
                        if($result->isValid()){
                                //Storing firstname,lastname of user
                                $auth = Zend_Auth::getInstance();
                                $storage = $auth->getStorage();
                                
$storage->write($authAdapter->getResultRowObject(
                                        
array('fullname','username','email','dob','gender')));
                                        return $this->_forward('index');}
                        else{
                                $this->view->loginMessage = "Either Email-id or 
password incorrect!";
                                }
                }
                        $this->view->form->$userForm;
        }       
                
        
                
}       


?>



--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Database-configuration-tp4033733p4035301.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to