1. Technology
Send to a Friend via Email
You can opt-out at any time. Please refer to our privacy policy for contact information.

Processing form data with PHP

By

1 of 2

Using a Form to Collect Data
Here we are going to learn how to take data from the user through an HTML form and then process it through a PHP program and output it. If you are interested in making PHP work with SQL you should visit this tutorial and if you are interested in sending data via email you should visit this tutorial as neither concepts will be covered in this lesson.

For this tutorial you will need to create two pages. On the first page we will create a simple HTML form to collect some data. Here is an example:

 <html> 
 <head><title>Test Page</title></head> 
 <body> 
 <h2>Data Collection</h2><p> 
 <form action="process.php" method="post"> 
 <table> 
 <tr><td>Name:</td><td><input type="text" name="Name" /></td></tr> 
 <tr><td>Age:</td><td><input type="text" name="Age" /></td></tr> 
 <tr><td colspan="2" align="center"><input type="submit" /></td></tr> 
 </table> 
 </form> 
 </body> 
 </html> 

This page will send the Name and Age data to the page process.php

Related Video
Basic PHP Syntax
Using PHP With HTML
  1. About.com
  2. Technology
  3. PHP / MySQL
  4. Learn PHP
  5. Collect user data with PHP Forms

©2014 About.com. All rights reserved.