SHARE
Facebook X Pinterest WhatsApp

PHP Tutorial: Order Form

Written By
thumbnail
Vince Barnes
Vince Barnes
Jan 4, 2005

We continue now by creating a simple order form.  The processing of forms
like this is one of the more common things to be done with server side languages
including PHP.  For our example we have chosen the component order form
from the Acme Widget Company (of course!)  Here’s the code for the entire
form:


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Acme Widget Company</title>
</head>
<body style="font-family: Arial">
<h1><br>
Acme Widget Company</h1>
<p>Component Order Form</p>

<FORM ACTION="processorder.php" method=post>
<table border=0>
<tr>
<td width=150>Item<br>
&nbsp;</td>
<td width=15>Quantity<br>
&nbsp;</td>
</tr>
<tr>
<td>Bases</td>
<td align="center"><input type="text" name="qtybases" size="3"
maxlength="3"></td>
</tr>
<tr>
<td>Stems</td>
<td align="center"><input type="text" name="qtystems" size="3" maxlength="3"></td>
</tr>
<tr>
<td>Tops</td>
<td align="center"><input type="text" name="qtytops" size="3"
maxlength="3"></td>
</tr>
<tr>
<td colspan="2" align="center"><br>
<input type="submit" value="Enter Order"></td>
</tr>
</table>
</form>

</body>
</html>


You can click here to see
what this form looks like in your browser.


Now let’s break it down.  As with our last example, most of the code you
see is ordinary HTML.  Notice, however, that the ACTION= on the FORM
statement points to a PHP file called processorder.php (the capitals we’ve used
here are only to highlight to code we’re talking about – it doesn’t make any
difference whether you use capitals or lowercase letters, except that the
filename may be case sensitive if your site is hosted on a Unix/Linux system.).


When the user hits the "enter order" button, the file whose name (URL) appears
in the ACTION statement will be loaded and the data the user typed into the form
elements will be passed to it.  The data will be identified to that file by
the field names used on the form, here "qtybases", "qtystems"  and "qtytops". 
For this reason it’s a good idea to use easily recognized and meaningful names,
such as ours are.


There’s really no PHP code in this form (which is why it’s in a file named with a
.html extension) so we’ll move right along to the file that will process our
order.

Continue to the next part of this Tutorial


Return to the Tutorial Series Index

Recommended for you...

PHP vs Javascript: Compare Web Development Languages
How Laravel Speeds Up App Development
Rob Gravelle
Aug 29, 2018
7 Ways to Start Learning JavaScript as a WordPress Developer
Exploring PhpSpreadsheet’s Formatting Capabilities
Rob Gravelle
Feb 26, 2018
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.