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
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel
Southwest USA
Irish Culture


dailyclick
All times in EST

Full Schedule
g
g PHP Site

BellaOnline's PHP Editor

g

Personal Activities Calendar Program - Integrating A Web Form Into A PHP Program

Guest Author - Diane Cipollo

In the last tutorial for the Personal Activities Calendar Program you built the HTML web form that you will use to collect the information about the activities you wish to add to your activities calendar program database. View Code for Sample Web Form

Now you are ready to begin coding the web application that will drive the calendar program. Most web applications are written as a group of small PHP programs that work together as a whole to run the application. This is an efficient method of writing a web application because it makes maintaining the individual sections of the application much easier.

We will begin coding the first of this group of PHP programs. This section will handle the collection of information for new activities and store that information in the database. In order to use the web form to collect this information, you will need the program to print the form to the webpage when it is needed. How will the program know when the web form is needed?

If you remember there are 11 pieces of information being collected by the web form variables.

act_title -- Title of activity

act_desc -- Description of activity

Time the activity will begin
act_month_1
act_day_1
act_year_1
act_hour_1

Time the activity will end
act_month_2
act_day_2
act_year_2
act_hour_2

act_status

If these variables are NOT empty, then the web form has already been filled out and submitted to the program. So of course, there is no need to print the form to the web browser again. But we really don't need to check all ten variables. Let's just check to see it the submit button on the web form has been used. We will use this line of code.

if(empty($_POST['submit'])) { print web form to browser }
else { process data }

What does this code say?

if(empty($_POST['submit'])) {print web form to browser}
If the submit variable is empty, the form has not been used yet. Therefore print the web form to the browser.

else { process data }
If the submit variable is not empty, then the web form has been filled out and submitted. In this case, process the incoming data.

We will name this program ActivityEntry.php3. And we will put this code just below the require_once statement for the config.php3 file. Here are the first few lines of this program. Take a look at the first few lines of the echo statement.

echo "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
. . .
</html>";

As you can see in the echo statement, the code for the web form is placed between quotation marks. Because of this, we must escape any quotation marks that are part of the HTML code for the web form. Above, the two quotation marks in the doctype tag has been escaped with a \. You will do this for every quotation mark in the web form code.






This site needs an editor - click to learn more!

Add Personal+Activities+Calendar+Program+%2D+Integrating+A+Web+Form+Into+A+PHP+Program to Twitter Add Personal+Activities+Calendar+Program+%2D+Integrating+A+Web+Form+Into+A+PHP+Program to Facebook Add Personal+Activities+Calendar+Program+%2D+Integrating+A+Web+Form+Into+A+PHP+Program to MySpace Add Personal+Activities+Calendar+Program+%2D+Integrating+A+Web+Form+Into+A+PHP+Program to Del.icio.us Digg Personal+Activities+Calendar+Program+%2D+Integrating+A+Web+Form+Into+A+PHP+Program Add Personal+Activities+Calendar+Program+%2D+Integrating+A+Web+Form+Into+A+PHP+Program to Yahoo My Web Add Personal+Activities+Calendar+Program+%2D+Integrating+A+Web+Form+Into+A+PHP+Program to Google Bookmarks Add Personal+Activities+Calendar+Program+%2D+Integrating+A+Web+Form+Into+A+PHP+Program to Stumbleupon Add Personal+Activities+Calendar+Program+%2D+Integrating+A+Web+Form+Into+A+PHP+Program 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