1. About.com
  2. Computing & Technology
  3. PHP / MySQL

Discuss in my forum

Processing form data with PHP

By , About.com Guide

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

©2012 About.com. All rights reserved. 

A part of The New York Times Company.