Form

Introduction

HTML form is usually used to pass values to PHP scripts.
Inside <form> tag, use action attribute to specify the PHP script to process the form data.

Code - HTML

<form action="test.php" method=get>
	First name: <input type="text" name="firstname"><br />
	Last name: <input type="text" name="lastname"><br />
	<input type="submit">
</form>

Code - PHP

<?php
	$firstname = $_GET['firstname'];
	$lastname = $_GET['lastname'];
	echo "Hello $firstname $lastname!";
?>

Demo

Open in new window

Task

Create an HTML form with two fields "Food" and "Drink".
When the form is submitted, display the values of the fields on the screen.

Reference

W3SCHOOLS.COM