phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Zend Framework Database: Creating Input Form

Tag: framework, zend, zend framework, database, form   Category: PHP Framework
post: 12 Apr 2008 read: 4,006


Zend Framework Database Step By Step Tutorial - Part 2: First step, we will create a form for inputing data. We create this form at User Controller. We just add method named "registerAction" as action for this controller.

Open "UserController.php" within application/controllers. Add following method:


  public function registerAction()
  {
    $request = $this->getRequest();
	
	$this->view->assign('action',"process");
    $this->view->assign('title','Member Registration');
	$this->view->assign('label_fname','First Name');
	$this->view->assign('label_lname','Last Name');	
	$this->view->assign('label_uname','User Name');	
	$this->view->assign('label_pass','Password');
	$this->view->assign('label_submit','Register');		
	$this->view->assign('description','Please enter this form completely:');		
  }

As we know, if we create action name "registerAction", we must create a view named "register.phtml". Ok, create a file named "register.phtml" within application/views/scripts/user. Enter following code:


<? include "header.phtml"; ?>
  <h1><?=$this->escape($this->title);?></h1>
  <div id="description">
    <?=$this->escape($this->description);?>
  </div>
  <form name="register" method="post" action="<?=$this->escape($this->action)?>">
  <table>
    <tr>
	  <td><?=$this->escape($this->label_fname)?></td>
	  <td><input type="text" name="first_name"></td>
	</tr>
    <tr>
	  <td><?=$this->escape($this->label_lname)?></td>
	  <td><input type="text" name="last_name"></td>
	</tr>	
    <tr>
	  <td><?=$this->escape($this->label_uname)?></td>
	  <td><input type="text" name="user_name"></td>
	</tr>	
    <tr>
	  <td><?=$this->escape($this->label_pass)?></td>
	  <td><input type="password" name="password"></td>
	</tr>	
  </table>
  <input type="submit" name="submit" value="<?=$this->escape($this->label_submit);?>">
  </form>
<? include "footer.phtml"; ?>

Point your browser to http://localhost/test/zend/helloworld/web_root/user/register



Series this article:
Zend Framework Database: Intro
Zend Framework Database: Creating Input Form
Zend Framework Database: Inputing Data to Database
Zend Framework Database: Inserting Expressions to a table
Zend Framework Database: Creating List of Data
Zend Framework Database: Creating Editing Form
Zend Framework Database: Updating Data
Zend Framework Database: Updating Data Use Update Query From Zend Framework
Zend Framework Database: Deleting Data
Zend Framework Database: Delete Query Style
Zend Framework Database: Summarizing Action Controller

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
SMS : Sending SMS with PHP and ActiveXperts (Part 1)

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


624
posting