Inputing Data to Database

After create form, now, we create action to input data to database. For this job, open "UserController.php" within application/controllers. Add a method named "processAction", with following code:
public function processAction()
{
$params = array('host' =>'localhost',
'username' =>'root',
'password' =>'admin',
'dbname' =>'zend'
);
$DB = new Zend_Db_Adapter_Pdo_Mysql($params);
$request = $this->getRequest();
$sql = "INSERT INTO `user`
(`first_name` , `last_name` ,`user_name` ,`password`)
VALUES
('".$request->getParam('first_name')."', '".$request-
>getParam('last_name')."', '".$request->getParam('user_name')."', MD5('".$request-
>getParam('password')."'))";
$DB->query($sql);
$this->view->assign('title','Registration Process');
$this->view->assign('description','Registration succes');
}

It is simple to understand it, isn't it?
Next, create view for this processAction. create a file named "process.phtml" within application/views/scripts/user
<? include "header.phtml"; ?>
<h1><?=$this->escape($this->title);?></h1>
<h2><?=$this->escape($this->description);?></h2>
<a href="list">Member List</a>
<? include "footer.phtml"; ?>
Now, point your browser to http://localhost:8050/test/zend/helloworld/web_root/user/register. Then, enter a user information such as:
Click registration button. You will get like this:

0 comments: