Book Image

CodeIgniter for Rapid PHP Application Development

By : David Upton
Book Image

CodeIgniter for Rapid PHP Application Development

By: David Upton

Overview of this book

<p>CodeIgniter (CI) is a powerful open-source PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. CodeIgniter is an MVC framework, similar in some ways to the Rails framework for Ruby, and is designed to enable, not overwhelm.<br /><br />This book explains how to work with CodeIgniter in a clear logical way. It is not a detailed guide to the syntax of CodeIgniter, but makes an ideal complement to the existing online CodeIgniter user guide, helping you grasp the bigger picture and bringing together many ideas to get your application development started as smoothly as possible.</p>
Table of Contents (21 chapters)
CodeIgniter for Rapid PHP Application Development
Credits
About the Author
About the Reviewers
Preface
Index

CI's Form Helper: Entering Data


Let's move on to how you use your HTML pages. One of the most important parts of any dynamic site is interaction with the users, and this usually means HTML forms. Writing forms is repetitive and boring.

The CI form helper is a very useful piece of code. It introduces a slightly different syntax, which makes form creation easier. Let's build a form to allow ourselves to enter data on our site about a new website. In a sites table, we want to enter the name, type, and URL of the website, and the date it was updated.

You can build the form as a simple HTML file, or you can build it inside a controller, pack it into a variable, then call a view, and pass the variable to the view. I'm doing the second.

Firstly, we have to load the form helper into the controller where we need to use it. Then, we put the following line in the controller's constructor function:

$this->load->helper('form');

and of course, we have to start the form.

Now, for the form fields, instead...