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


dailyclick
All times in EST

Full Schedule
g
g PHP Site

BellaOnline's PHP Editor

g

Personal Activities Calendar Program - Initialize And Pass Argument Variables With A Function

Guest Author - Diane Cipollo

In the last part of the Personal Activities Calendar Program we built the PHP function that will send the Activity Entry web form to the browser. So far we used a PHP if statement to test if the web form has been submitted and if it hasn't, then the program will call the function which will send the form to the browser.

However, we need to add one more thing to this step in the program. Because the form has not been submitted yet, the input fields used in the form do not have any data assigned to them. So we do not have any data to pass with the function arguments (which are variables). So we need to initialize these variables to null before we send them. (If you need to refresh you memory about PHP functions, arguments and function calls, read my previous article.) We will put the code that initializes the variables to null just before the function call. In the table below, the input fields used in the web form are in the column on the left and the names we will give to our argument variables are in the right column.

Input Fields

act_title
act_desc
act_month_1
act_day_1
act_year_1
act_hour_1
act_month_2
act_day_2
act_year_2
act_hour_2
act_status
Function Arguments

$pass_act_title
$pass_act_desc
$pass_act_month_1
$pass_act_day_1
$pass_act_year_1
$pass_act_hour_1
$pass_act_month_2
$pass_act_day_2
$pass_act_year_2
$pass_act_hour_2
$pass_act_status

So far the if statement looks like this.

if(empty($_POST['submit']))
{
Activity_Entry_Form( );
}


Now we need to write the code to initialize the variables.

$pass_act_title = "";
$pass_act_desc = "";
$pass_act_month_1 = "";
$pass_act_day_1 = "";
$pass_act_year_1 = "";
$pass_act_hour_1 = "";
$pass_act_month_2 = "";
$pass_act_day_2 = "";
$pass_act_year_2 = "";
$pass_act_hour_2 = "";
$pass_act_status = "";


Next we need to add the arguments to the function call.

Activity_Entry_Form( $pass_act_title,
$pass_act_desc,
$pass_act_month_1,
$pass_act_day_1,
$pass_act_year_1,
$pass_act_hour_1,
$pass_act_month_2,
$pass_act_day_2,
$pass_act_year_2,
$pass_act_hour_2,
$pass_act_status );

Note--The arrow indicates that the code is wrapped to a second line and could really be all on one line.

Here are the finished changes to the ActivityEntry.php3 file.






This site needs an editor - click to learn more!

Add Personal+Activities+Calendar+Program+%2D+Initialize+And+Pass+Argument+Variables+With+A+Function to Twitter Add Personal+Activities+Calendar+Program+%2D+Initialize+And+Pass+Argument+Variables+With+A+Function to Facebook Add Personal+Activities+Calendar+Program+%2D+Initialize+And+Pass+Argument+Variables+With+A+Function to MySpace Add Personal+Activities+Calendar+Program+%2D+Initialize+And+Pass+Argument+Variables+With+A+Function to Del.icio.us Digg Personal+Activities+Calendar+Program+%2D+Initialize+And+Pass+Argument+Variables+With+A+Function Add Personal+Activities+Calendar+Program+%2D+Initialize+And+Pass+Argument+Variables+With+A+Function to Yahoo My Web Add Personal+Activities+Calendar+Program+%2D+Initialize+And+Pass+Argument+Variables+With+A+Function to Google Bookmarks Add Personal+Activities+Calendar+Program+%2D+Initialize+And+Pass+Argument+Variables+With+A+Function to Stumbleupon Add Personal+Activities+Calendar+Program+%2D+Initialize+And+Pass+Argument+Variables+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