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

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

new
Houseplants
Romance Movies
Creativity
Family Travel
Southwest USA
Irish Culture
Home Finance


dailyclick
All times in EST

Full Schedule
g
g PHP Site

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!

Add Personal+Activities+Calendar+Program+%2D+Printing+The+Web+Form+With+A+Function to Twitter Add Personal+Activities+Calendar+Program+%2D+Printing+The+Web+Form+With+A+Function to Facebook Add Personal+Activities+Calendar+Program+%2D+Printing+The+Web+Form+With+A+Function to MySpace Add Personal+Activities+Calendar+Program+%2D+Printing+The+Web+Form+With+A+Function to Del.icio.us Digg Personal+Activities+Calendar+Program+%2D+Printing+The+Web+Form+With+A+Function Add Personal+Activities+Calendar+Program+%2D+Printing+The+Web+Form+With+A+Function to Yahoo My Web Add Personal+Activities+Calendar+Program+%2D+Printing+The+Web+Form+With+A+Function to Google Bookmarks Add Personal+Activities+Calendar+Program+%2D+Printing+The+Web+Form+With+A+Function to Stumbleupon Add Personal+Activities+Calendar+Program+%2D+Printing+The+Web+Form+With+A+Function to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


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


Content copyright © 2014 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.

g


g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


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


BellaOnline Editor