PHP Tutorial – PHP Forms

In this tutorial we are going to learn how to take data entered by the user in an HTML form and process it into PHP script and display the output.

We need two pages here namely the process.php and the test.php or test.html.

On our test.html we are going to create a form to collect some data. Here is the code:

<html> <head><title>Test Page</title></head> 
<form action="process.php" method="post">
Name: <input type="text" name="name">
Age: <input type="text" name="age">
<input type="submit" value="Submit">

This page will submit the Name and Age data to the page process.php when the submit button is clicked.

Next we are going to create the process.php. This page will display the Name and Age that the user entered in our test.html. Here is the script:

<title>Processing form data with PHP</title>
Welcome <?php echo $_POST["name"];?>.<br/>
You are <?php echo $_POST["age"];?> years old
, , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.