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 184181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:14:49+00:00 2026-05-11T15:14:49+00:00

We have to insert the Date of Birth(which is a drop down box containing

  • 0

We have to insert the Date of Birth(which is a drop down box containing DD/MM/YYYY) in MySql by validating it. How can it be done?


Its a form validation for Date of Birth which is input by user from the options in dropdown menu.My question is how to insert that input DOB in MySql using PHP

  • 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. 2026-05-11T15:14:50+00:00Added an answer on May 11, 2026 at 3:14 pm

    Your question is a bit confusing. Inserting data ‘by validating it’ doesn’t make sense.

    If you want to know how to insert data, well that’s a basic MySQL question which is probably best answered by consulting the online documentation.

    If you want to know how to validate the data, you’re going to have to specify the kind of validation you want–as sanders has answered. It’s sort of like asking ‘how do I make a GUI?’ There are infinite ways you can do it. The question is too vague.

    If you just want to check to see if the value submitted is a valid date, a quick and dirty (lazy) way of doing it is just to insert it into the table (assuming you have a column of the DATE/DATETIME type), then make a follow-up query to retrieve the value stored. If the stored value is that data type’s ‘zero’ value (i.e. ‘0000-00-00’ or ‘0000-00-00 00:00:00’), then the submitted value was not a valid date.

    So your code would look something like:

    <? $month = mysql_real_escape_string($_POST['month']); $day = mysql_real_escape_string($_POST['day']); $year = mysql_real_escape_string($_POST['year']); $query = 'INSERT INTO my_table (`birthday`) VALUES ('$year-$month-$day')'; mysql_query($query); $query = 'SELECT `birthday` FROM my_table WHERE `id`=LAST_INSERT_ID()'; $qid = mysql_query($query); $res = mysql_fetch_object($query); if ($res->birthday == '0000-00-00') {     // submitted date was invalid } ?> 

    Of course, there are many drawbacks to the above code. Ideally, you probably want to validate the data before you insert it, and if you are updating a record rather than inserting a new one, then you will need to fetch the original value before it is overwritten with an invalid one.

    BTW: I think you meant to say ‘drop-down list’ or ‘select list.’ A drop-down menu is something else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Oracle Date type to which I need to insert the current
I have a field of type date in MySQL. When I try to insert
I have used date(mm/dd/yyyy) format to insert get date in PHP but when i
I have a text field where the user can insert the date and the
I have an insert script with mySQL. I need to place the date and
I am trying to insert date and time into mysql datetime field. When a
I have created a Temp table(#TempTable). I am trying to insert the date to
I am trying to insert a future date into a MySQL table from PHP.
Just wondering how I would insert the date 01/01/4000BC into oracle Have tried the
I have the field: APP_DATE (smalldatetime) I'm doing this query: INSERT INTO table (TYPE,

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.