Any advice for handling date entry on a form

software development


I’m looking for advice on a combination PHP/MySQL programing and human factors problem.

Last week, I threw together a form to allow anglers to report tagged fish to us. It’s PHP and on Submit, it writes a record to a MySQL database. If one of the four required fields out of the 8 fields are not submitted, the script rejects the record and tells the angler to use the back button and try again.

I’ve been vacillating about how to handle the date input on the form. While I show them the format I’d like on the form so it works with datetime, yyyy-mm-dd, I haven’t made the date a required field. Since the date is stored in a datetime field in the database, currently if an angler enters a date in a different format, the date is blank in the record.

I’ve been thinking that since the date is not as important as the tag report, I don’t want to frustrate the angler by giving him an error message and requiring him to go back and try the date entry again. Rather than extensive programming to recognize and convert many different date formats, I thought that I might instead catch the date input from the form in a new string field as well, so later a human can interpret it. I think at the most I’ll get around 100, maybe less, with this form.

Recently, my colleges have suggested that a calendar control might work on the page, so the angler might point and click a little calendar to construct the date in the correct format, like they might have seen on online payment sites. But I’m not so sure that it would be easier for the public to use such a control, and so far, the only one’s I’ve found are the kind used to schedule events on a calendar. Are there some free/shareware php srcipts or code examples just to help date entry out there?

One thing I’ve considered in to split the date into three boxes on the form: year, month, and day, check the year and make it 2010 if only 10 is entered, then calculate the datetime field from the three variables.

Have you ever had trouble with hackers finding your form and entering a bunch of garbage? Links to Russian porn, that kind of thing?

This signature line intentionally blank.


There’s a lot of free javascript and php calendar widgets available, personally I would just use 3 dropdown boxes. No html form is safe from bad data submission without serious server side validation, but with the dropdowns you provide an easy to use and understand method of controlling the data you want.


+1 for the dropdown boxes.

I’d like more details about the Russian pr0n :slight_smile:

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


I found a nice calendar control at that has several options of display. I tried the calendar display and I got it to work passing its date into the database ( but I can’t figure out how I’m supposed to position it in my existing form so it appears where the old date entry is going to come out. It looks like it wasn’t enough to just cram it in to the form like:

Date Recovered, yyyy-mo-da * <?php //get class into the page require_once('../calendar/classes/tc_calendar.php');

//instantiate class and set properties
$myCalendar = new tc_calendar(“date2”);
$myCalendar->setDate(date(‘d’), date(‘m’), date(‘Y’));
$myCalendar->setYearInterval(2009, 2011);
$myCalendar->dateAllow(‘2010-04-01’, ‘2011-04-01’, false);
//output the calendar

Comments ... ...

This signature line intentionally blank.


Got it:

I just had to slip the php code in the

block, replacing the stuff.

This signature line intentionally blank.


That’s a sweet calendar. Nice job.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost