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...