PHP form date auto compiling

Dorn's picture

They have: 42 posts

Joined: Jul 2001

OK... I admit it. I have no idea what to call what I am asking about.

Here is what I need to figure out.
I have a form that is using PHP. It validates and submits to a DB and email. There is a portion of the for that requires the user to select a date. Month, Day, & Year. The problem is that each month has a different amount of days in it. I want to remove human error by making the correct amount of days show determined by the month that is currently selected.

Is there a function (term?) that will compile the 'days' option based on which month is selected?

Thank you in advance for any information.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

wow, did you ever come to the right place at the right mktime!

*groan* sorry, it's been a long day...

In this case it would be better to use an array that determines what you need (and JavaScript to adjust the form entries) or to do error checking in the background.

For the JavaScript, I'm not sure -- I don't do that sort of thing often enough to have it at my finger/braintips.

For the PHP -- http://www.php.net/manual/en/function.cal-days-in-month.php should help you out if you want to refresh the page with the correct information. parent information and as always, the user comments are very helpful.

Dorn's picture

They have: 42 posts

Joined: Jul 2001

Suzanne! you are the knower of all things...

next rounds on me!

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Not me, dahlink, it's the machine, the machines, I tell you! They know...

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.