All pastes #970188 Raw Edit

Something

public text v1 · immutable
·published 2008-04-03 21:39 UTC
rendered paste body
Contoller:

public function loginAction()
    {
		# assign the form to view
		$request = $this->getRequest();
		$form = new WebForm;		
		$form->addReqField('username', 'Username');
		$form->addReqField('password', 'Password', false, '', WF_PASSWORD);
		
		# check if we have a POST request
        if ($request->isPost()) {
            if ($form->readAndValidate($request->getPost())) {
				$form->dbPrep();
				$auth = Zend_Auth::getInstance();
				$adapter = new MyAuthAdapter($form->dbGetFields());
		        $result = $auth->authenticate($adapter);
				if ($result->isValid()) {
		            $this->_helper->redirector('index', 'index');
		        } else {
					$form->WFmsg = 'Invalid credentials provided. Please review login data.';
				}
	        } else {
				$form->WFmsg = 'Please review data and correct all <strong>highlighted fields</strong> below.';
			}
        }
		
		# send wfEcho to view
		$this->view->wfEcho = new WFEchoKit($form);
    }


View:


<form class="webform" enctype="multipart/form-data" method="post" action="<?=$_SERVER['REQUEST_URI']?>">
	<input type="hidden" name="act" value="save">	
	<ul>	
<?
		# print any errors to user
		$this->wfEcho->echoMsg();
		
		# output the form fields
		$this->wfEcho->echoInputRow('username');
		$this->wfEcho->echoInputRow('password');
		
?>
		<li class="buttons">
			<input id="saveForm" class="btTxt" type="submit" value="Login" />or <a href="/">Cancel</a>
		</li>
	</ul>
</form>