Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7055967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:48:42+00:00 2026-05-28T03:48:42+00:00

I have 3 dropdowns on a form for the user to choose their birthday.

  • 0

I have 3 dropdowns on a form for the user to choose their birthday. One for date, one for month and one for year.

Right now I cam preparing the date given by the user like this:

$date = sanitize($_POST['year']).'-'.sanitize($_POST['month']).'-'.sanitize($_POST['day']);

and inserting $date into the database in a DATE field. I want to be able to do operations based on this field’s values, like sorting by date etc…

Is this the right way to prepare the data or should there not be any hyphens?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:48:42+00:00Added an answer on May 28, 2026 at 3:48 am

    According to the MySQL manual page on DATE, the proper format is 'YYYY-MM-DD', so this appears as if it would work and allow you use all of the MySQL date and date comparison operations and functions.

    However, you should consider validating user input before sending it to the database (never trust the security or validity of user input). Maybe you should run it through PHP’s date() to make sure that the date you are inserting is valid:

    $date = date('Y-m-d', strtotime($_POST['month'].'-'.$_POST['day'].'-'.$_POST['year']));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that allows the user to choose a country. Depending on
I have a form where I have 4 dropdowns Country, State, District and City.
I have a form with 4 dropdowns on it. The default selected option in
I have a form with multiple dropdowns consisting of multiple values. I'm trying to
I am using Asp.net dropdownlist in one of my form ..I have two dropdown
I have a dropdown which you choose one of three values <select id=FilterType name=FilterType>
I have two forms: one that takes user information (name, birthdate, etc): formA. And
I have a simple form for a hotel accommodation tool. User selects the number
I have 4 groups of checkboxes and corresponding dropdowns on a form. Is there
I have a form with 3 dropdowns that I want to toggle the disabled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.