logo
g Text Version
Auto
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Society & Culture
Sports
Travel & Leisure
TV & Movies

dailyclick
Bored? Games!
Postcards
Astrology
Take a Quiz
Rate My Photo

new
Spirituality
Home Improvement
Vegetarian
NASCAR
Southcentral USA


dailyclick
All times in EST

Autism Spectrum Disorders: 4:00 PM

Full Schedule
g
g PHP Site
Editor Wanted
BellaOnline's PHP Editor

g

Personal Activities Calendar Program - Printing The Web Form With A Function
Guest Author - Diane Cipollo

In this tutorial, we will continue to work on the ActivityEntry.php3 program file for the Personal Activities Calendar Program project. So far we have written the code for the part of the program that tests if the Activity Entry web form has been filled out and submitted to the program.

if(empty($_POST['submit'])) { echo form to webpage }
else { process data }

If the $_POST['submit'] is empty, the submit button on the web form has not been used and the form has not been filled out. In this case, the program will send the web form to the browser via an echo statement. Here is the code so far. This works fine if this was the only time that the program needed to send the web form to the browser. But we need to consider that this same web form will be sent to the browser in three instances.

  1. As we have coded our program so far, the form will be sent when the form has not been filled out ($_POST['submit'] is empty) and we want to add a new activity to the calendar.
  2. Once the form is filled out, the $_POST['submit'] variable will not be empty. The program will then check for mistakes in the submitted data. If there is missing information because you did not fill out the form completely, an error message is sent to the browser along with the web form again.
  3. You might need to change the information about an activity that you have previously entered into the database. For example, you might want to change the status from incomplete to complete. When you need to edit a previously entered activity, the form will be sent to the browser for the changes.
As of now, the echo statement is still coded within the if statement in the ActivityEntry.php3 file.

if(empty($_POST['submit'])) { echo form to webpage }

But we will need to use this same echo statement for all three instances. So we can make our program more efficient if we change the echo statement to a function. Then any time the program needs the web form, we will call the function. Therefore, we will need to change the echo statement in the code above to a function call.

if(empty($_POST['submit'])) { function call }

Next →







This site needs an editor - click to learn more!

RSS | Related Articles | Previous Features | Site Map


Content copyright © 2008 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

Digg! g delicious Save to Del.icio.us

g


For FREE email updates, subscribe to the PHP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor

g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Driving Amount
Much more
Slightly more
Slightly less
Much less

g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2008 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor