====== Web Development Lesson 8 - Forms ======
===== Inputs =====
==== Objective ====
In this activity you will create a form and use it to pass data from one page to another.
==== Setup ====
* We will continue to work with 'form.php' and 'process_form.php'. If you need the code again, here it is.
**form.php**
==== Submit a Form ====
* Open 'form.php'. We will display our form here.
* Add a new line below the opening tag.
* Type 'form' and select the option that appears.
* The
tags.
* Now add our hero options as 'submit' buttons.
* Setting the type to 'submit' means that when we click the button it will submit the form and send the data. Both buttons will do this.
* name is the parameter name to be sent. Submit buttons will often be named 'submit' and not contain data, but sometimes there will be two forms on a page (or sent to a page) and you need to know which one to process. We use that here to differentiate the selected heroes.
* The value is the text that will appear on the button.
* Save and upload the file, then open the page.
* Click on your chosen hero then check the results. Do you see your hero's name?
* This is an usual way to use a Submit button, but it's valid. Let's look at other options.
==== Text Input ====
* Let's create a form to add heroes to our database.
* We'll need input fields for the name, whether they're a hero or a villain, the year they first appeared in Marvel comics (or elsewhere) and what the source of their power is.
* We could use a table to present our form with labels on the left and inputs on the right, but that isn't responsive, that is, it won't adapt to smaller screens.
* Instead, we'll use a list, where each label / input pair is a list item.
* Delete everything inside the
tag and add the following code.
* The first field for the hero's name can be a simple text field.