Developing Webs logo
Google
Web DW-Main DW-Photoshop
Visit the message board for solutions or post a question Check out the Classes offered for free at Developing Webs Voice Chat submit a tutorial, resources, article, font for publication consideration and earn a one way link back to your site Get more specifics about the Developing Webs Voice chat room and its room members View the current news at Developing Webs alternative sites which are resources for your d3evelopment needs Join Developing Webs Chat Link to us on your web page to help support this resource! Check out Developing Webs At yahoo groups! Developing Webs Home Adobe Photoshop Tutorials Macromedia Flash Tutorials Jasc Paint Shop Pro Tutorials Adobe Illustrator Animation basics Some Basic PHP tutorials Perl Tutorials HTML Tutorials Cascading Style Sheets javascript Front Page Tutorials Macromedia Dream Weaver Tutorials dreamweaver Publishing your site, FTP, ChMod, Promotions
RSS Newsfeed
for your site
DW News
Calendar
DW Forum
Right click on button and copy shortcut

Add to My Yahoo!

Reminder
Remember to book mark this site!



Request a Tutorial

Creating The PHP Form Processor

This tutorial is to help out those following the book PHP and mySQL in web development.

1. Open a new Notepad document. Click file=>save and save this as an html doc on your desktop, with all files showing in the save as type. Save this with the name orderprocessing.php

2. PHP documents follow HTML tags as well as PHP tags. The basic layout of this form will be done in HTML. 

The next step is to define the html, head and body of the html. The head is where the title goes and the body is where the contents of the page goes that you see. The head ends prior to the start of the body. You should add these to your document so it looks like this:

<HTML>
<HEAD><TITLE>Bob's Auto Parts - Order Results</TITLE>
</HEAD>
<BODY>
</BODY>

</HTML>

4. The next step is to realize what you need to recreate this form. Once we decide what we need, we will have to design our page in a way that html can support the layout.

The order that is processed will have the same Header as your form, Bob's Auto Parts, But the name in the H@ tag is slightly different. It should be Order Results.

<HTML>
<HEAD><TITLE>Bob's Auto Parts - Order Results</TITLE>
</HEAD>
<BODY>
<H1>Bob's Auto Parts</H1>
<H2>Order Results</H2>

</BODY>
</HTML>

5. Under the Order results we would like PHP to show us the Order Processed. The PHP server will process any command in PHP language. We can place a command between a <? and ?>. What is after the work "echo" will be output to your HTML, therefore it can be written in HTML

Type this in:

<HTML>
<HEAD><TITLE>Bob's Auto Parts - Order Results</TITLE>
</HEAD>
<BODY>
<H1>Bob's Auto Parts</H1>
<H2>Order Results</H2>
<?
echo "<P>Order Processed.";
?>

</BODY>
</HTML>

6. We can add comment code with the format below. PHP will not interpret what's in a comment tag, however it helps to add them when getting into longer pages where you need note each part.

/*this is a comment
*/

7. The echo tag above shows static content in that we posted the text in the tag to be displayed. It can also be used for dynamic content.  The time and date. The word date is a functions and the contents of the parentheses are augments to specify the function.

  • H=hour in 24 hour time,
  • i= minutes,
  • j=day of the month,
  • S= ordinal suffix,
  • F=year

<?
echo "<P>Order Processed.";
echo date("H:i, jS F")
echo "<br>";

?>

8. We can use PHP to pass variables to the form and display them. In our form, we created the variables tireqty, oilqty, sparkplugqty. The $ will  tell PHP this is a variable.

<?
echo "<P>Order Processed.";
echo date("H:i, jS F");
echo "<br>";
echo $tireqty." tires<BR>";
echo $oilqty." bottles of oil<BR>";
echo $sparkplugqty." spark plugs<BR>";
?>

 

9. The resulting PHP doc will look like this:

<HTML>
<HEAD><TITLE>Bob's Auto Parts - Order Results</TITLE>
</HEAD>
<BODY>
<H1>Bob's Auto Parts</H1>
<H2>Order Results</H2>
<?
echo "<P>Order Processed.";
echo date("H:i, jS F");
echo "<br>";
echo $tireqty." tires<BR>";
echo $oilqty." bottles of oil<BR>";
echo $sparkplugqty." spark plugs<BR>";
?>

</BODY>
</HTML>

Continue here to do tutorial 3 and
  • add the calculations to your script
  • make the calculations show in your processed order.


"Building The Web Into a Nicer Place -- One Site At A Time"
Developing Webs Group Copyright © 2001-2024 All Rights Reserved
Privacy and Legal