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


dailyclick
All times in EST

Autism Spectrum Disorders: 4:00 PM

Full Schedule
g
g PHP Site

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!

Add Personal+Activities+Calendar+Program+%2D+Error+Message+For+Missing+Form+Data to Twitter Add Personal+Activities+Calendar+Program+%2D+Error+Message+For+Missing+Form+Data to Facebook Add Personal+Activities+Calendar+Program+%2D+Error+Message+For+Missing+Form+Data to MySpace Add Personal+Activities+Calendar+Program+%2D+Error+Message+For+Missing+Form+Data to Del.icio.us Digg Personal+Activities+Calendar+Program+%2D+Error+Message+For+Missing+Form+Data Add Personal+Activities+Calendar+Program+%2D+Error+Message+For+Missing+Form+Data to Yahoo My Web Add Personal+Activities+Calendar+Program+%2D+Error+Message+For+Missing+Form+Data to Google Bookmarks Add Personal+Activities+Calendar+Program+%2D+Error+Message+For+Missing+Form+Data to Stumbleupon Add Personal+Activities+Calendar+Program+%2D+Error+Message+For+Missing+Form+Data 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