Personal Activities Calendar Program - Collect Data Into Your PHP Program With An HTML Web Form
|In the last tutorial, we began a Personal Activities Calendar Program written in PHP and we created a database table to store information about scheduled activities and events. Now that we have our table created in our database, the next step is to create an HTML web form that we can use to collect the specifics about new activities and then send that information to the php program. |
Our first step in designing the web form is to analyze each piece of information that we will be collecting and decide which type of HTML form tag to use to collect that piece of data. If you are unfamiliar with HTML form tags, check out my HTML site here at BellaOnline.
In the last tutorial, we called the first field in our activities table the act_ID field which is a unique identifier for each record. Because this table field is set to auto increment, we don't need to collect any data for the field with our web form.
The title of the activity or event is just a short line of text so we can use an HTML text input tag to collect this.
The description of the activity could be very short or quite detailed. So we will use the textarea tag for this field.
These input fields will collect the beginning date (month, day, year, hour) of the activity. To prevent confusion caused by incorrectly typed data, it is better to use the HTML select tag in the web form for the date information. One tag will display a drop-down list of the months of the year and a second tag will display the days of the month. You guessed it, the third tag will display a span of years. Of course, this span can include as many years as you need. However, you can omit this third tag if your activities program is for just a yearly calendar. The names of the months are displayed in text format (such as January, February). This will make the web form more user friendly. Finally, one more select tag will display the hour of the day that the activity is scheduled for (in one half hour increments).
We will create a second group of these tags for the ending date (month, day, year, hour) of the activity. We will use a number one on the end of the beginning date input fields and a number two on the end of the second group.
After the date and time is collected by the tags we just discussed, the program will convert the beginning and ending date/time to a Unix timestamp and store the timestamp in the table. Since this is done by the program, we will not need to have a tag for these fields in our web form.
When you first enter an activity into the calendar, the act_status of the activity is set to incomplete by default. However, you will want to update the status of the activity to complete at a later date. We will use a radio button input tag that will allow you to switch the status from incomplete to complete.
This site needs an editor - click to learn more!
Editor's Picks Articles
Top Ten Articles
Content copyright © 2022 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.