Open your index.php file (see Create project folder) and follow these steps:
1. Add an HTML html element and a body inside it.
<html><body></body></html>
2. Add an HTML form element inside the body with blank action and method attributes (we’ll set them later).
<form action="" method=""></form>
3. Add an HTML div element inside the form and add a label and an input element inside it for the first name field.
<div> <label>First Name:</label> <input name="first_name"> </div>
4. Repeat step 3 for the last name field.
5. Add an HTML button element inside the form with inner text: submit.
<button>Submit</button>
6. Try running the code. Notice it does nothing when submitted as the action and method aren’t set. Set the action to "process_my_form.php" and the method to "get" so we can process it in the next stage.
The final code should look something like this:
<html><body><form action="process_my_form.php" method="get">
<div> <label>First Name:</label> <input name="first_name"> </div>
<div> <label>Last Name:</label> <input name="last_name"> </div>
<button>Submit</button>
</form></body></html>
Parent topic: Example 2
Top comments (0)