The most common use for PHP code (or any server side code for that matter) is processing information contained in forms. To demonstrate this we are going to build an order form for a fictional company; High Class Computer Supplies. We are going to use the form shown here;
This form allows users to enter numbers to show how many of each item they want to order and an address (to mail their order to). To create the form, copy the code shown below and paste it into your text editor and save it as orderform.html. If you are confused about forms, go back and check Section 2.
<html>
<head>
<title>Order Form </title>
</head>
<body>
<form name="orderForm" id="orderForm" method="post" action="processOrder.php">
<table width="350" border="8" align="center" cellpadding="10" cellspacing="1" bordercolor="#000000" bgcolor="#EAFFFF">
<tr bgcolor="#CCCCCC">
<td width="150">Item</td>
<td width="165">Quantity</td>
</tr>
<tr>
<td>Hard Drives </td>
<td><input name="hd_qty" type="text" id="hd_qty" /></td>
</tr>
<tr>
<td>Monitors</td>
<td><input name="mon_qty" type="text" id="mon_qty" /></td>
</tr>
<tr>
<td>Printers</td>
<td><input name="pr_qty" type="text" id="pr_qty" /></td>
</tr>
<tr>
<td>Address</td>
<td><input name="address" type="text" id="address" /></td>
</tr>
<tr>
<td colspan="2">
<div align="right">
<input type="submit" name="Submit" value="Submit Order" />
</div></td>
</tr>
</table>
</form>
</body>
</html>
Notice that the form is set up to send the data to a page called processOrder.php. This page does not exist yet, we will create it in a moment. This form has four text fields, called hd_qty (hard drive quantity), mon_qty (monitor quantity), pr_qty (printer quantity), and address. These names are important, as we use them to get the information entered into each text field.
Notice also the use of camel case in the file name. Camel case means two or more words joined together with the first word in lower case and the other words with an initial capital letter, e.g. myFirstPage. The capitalization makes it easier to pick out the component words in the name.
next...create processOrder.php
