Birthdate form field!

0 Theodore Rees · March 30, 2015
I've been stuck trying to figure out how to create a birthdate field for my website with three drop down menus like what Bucky has created on this site! Any advice on how to get this started would be very helpful!

Post a Reply

Replies

Oldest  Newest  Rating
0 Sho Carter · March 31, 2015
....If you have a table already, then add this:

ALTER TABLE [table name goes here]
ADD COLUMN birthdate DATE AFTER [column you'd like this to be put after]


Then, when you intend to save data into this field, you can either have three input fields, one for day, one for month and one for year.
Then do something like this:

<?php
# set initial validation boolean
$valid = FALSE;

if( is_numeric( $_POST['day'] ) && is_numeric( $_POST['month'] ) && is_numeric( $_POST['year'] ))
{
   $valid = TRUE;
   $date = "{$_POST['year']}-{$_POST['month']}-{$_POST['day']}"; # (basically YYYY-MM-DD

   # THEN INSERT INTO DATABASE
}
  • 1

PHP

107,048 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators