g
Printer Friendly Version

editor  
BellaOnline's PHP Editor
 

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

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!

PHP Site @ BellaOnline
View This Article in Regular Layout

Content copyright © 2013 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 Editor Wanted for details.



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


BellaOnline Editor