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
Jokes & Riddles
Astronomy
Philosophy
Public Health
Canadian Culture


dailyclick
All times in EST

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

g

Personal Activities Calendar Program - Error Message For Missing Form Data
Guest Author - Diane Cipollo

In the last tutorial, we wrote the part of the Activity Entry script that will handle the possibility that the web form has been submitted but the user has not supplied all the required data. First, we set the values for the variables that we will pass to the Activity_Entry_Form function. The value for each variable is set to null if the input data is missing and, if not, it is set to the value of the $POST[''] data. Finally, we set the $error_message variable to yes if there is missing data from any of the required form fields. This will tell the program to display an error message when it displays the web form again. Now, let's work on handling the error message.

There are two changes we need to make to the Activity Entry script. Because we will be passing this new $error_message variable with the function call, we need to add this variable to the list of parameter variables that are sent to the function.

//If $error_message has been changed to yes, call function to print form again

if ($error_message == "yes")
{
Activity_Entry_Form( $error_message, $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 code above is wrapped. It could really be all on one line.

Also, because we will be coding the Activity_Entry_Form function to expect this new variable every time it is called, it will be expecting it even when the form is displayed for the first time. Therefore, we need to add the variable to the function call in the first part of the script. But we can't send this variable without initiating it first. So let's add that to the code too.

//If the $_POST submit is empty, call function to display form for the first time

if(empty($_POST['submit']))
{ $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 = "";

//Set the $error_message to null
$error_message = "";


Activity_Entry_Form( $error_message, $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 code above is wrapped. It could really be all on one line.

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