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

  • Home
  • SEARCH
  • 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 8504673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:06:06+00:00 2026-06-11T02:06:06+00:00

I am able to retrieve the date of birth from the database and populate

  • 0

I am able to retrieve the date of birth from the database and populate it in a option tag after the user has entered the date of birth. However, if the user updates anything else in the form the option value starts updating the database with the wrong date of birth. It seems that it’s counting backwards for some reason. How to do I resolve this matter?

if($_POST){
$dob = date('Y-m-d',strtotime($_POST['year']."-". $_POST['month']."-".$_POST['day'])); 

$retur = $userObj->updateProfile($dob);
}

public function updateProfile($dob){
$db = db_mysql::getInstance();
$qr = $db->query("UPDATE ".USERS." SET dob = $dob WHERE id = '".$udata."'") or die(mysql_error()); 

    return $udata;
 }
<label>Date of Birth:</label>
<select style="background-color: #D6CFD4;" name="month">
 <option value="{date('F',strtotime($udata.dob))}">{date('F',strtotime($udata.dob))}</option>
 <option value="01">January</option>
 <option value="02">Febuary</option>
<select style="background-color: #D6CFD4;" name="day">
 <option value="{date('d',strtotime($udata.dob))}">{date('d',strtotime($udata.dob))}</option>
 <option value="01">01</option>
 <option value="02">02</option>
<select style="background-color: #D6CFD4;" name="year">
 <option value="{date('Y',strtotime($udata.dob))}">{date('Y',strtotime($udata.dob))}</option>
 <option value="2012">2012</option>
 <option value="2011">2011</option>
  • 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-06-11T02:06:07+00:00Added an answer on June 11, 2026 at 2:06 am

    Your query is not very clear with the data you provided but here goes:

    $dob is a string from what I understand, in the format YYYY-MM-DD.
    updateProfile appears to be OK but I don’t know where the $udata comes from. If what you posted is the full function, then $udata is always empty and you return empty back.

    As for the template, I don’t know how you generate the HTML for the option buttons. It does seem however that you could be overwriting existing options i.e. what if for the month select the user is born in February. The first line will be duplicate with the third:

    <option value="{date('F',strtotime($udata.dob))}">{date('F',strtotime($udata.dob))}</option>
    <option value="01">January</option>
    <option value="02">Febuary</option>
    

    A couple of suggestions:

    It doesn’t appear that you are checking input. No matter how secure you think your app is, there is always someone that might find a way to interfere with it. Using $_POST[‘year’] etc. without sanitizing them or even casting them as integers is not ideal.

    You are not using bound parameters which is a must to ensure you are not vulnurable to SQL Injection attacks. It might be far fetched but if somehow the updateProfile receives this as $dob:

    $dob = "1;DROP users; --"
    

    then you are in trouble.

    Final suggestion is to check your select statements. I would do this:

    <select style="background-color: #D6CFD4;" name="day">
        <?php 
            for ($i = 1; $i < 32; $i++) {
                $dob_day  = (int) date('d', strtotime($udata.dob));
                $selected = ($i == $dob_day) ? " selected='selected'" : '';
    
                echo "<option value='{$i}'{$selected}>{$i}</option>";
            }
        ?>
    </select>
    

    You can repeat the process for the month and the year. This process though will not create necessarily a valid date. For instance what if someone selects 31 for the day and 02 for the month i.e. February.

    Final suggestion is (if possible) to use a datetime control which would effectively do all the hard work for you. All you will have to do is just pass the dob string to it and when the user is updating their dob, it will post back data that your app can easily parse, and more importantly the dates will always be valid i.e. no 31st of February possibility at least from the UI. Example

    HTH.

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

Sidebar

Related Questions

I am not able to retrieve the data from the server. I am not
Currently I am able to retrieve data from a MySQL db by using HTTP
i'm be able to retrieve the region format of the user, ad example it_IT
In PHP I am able to retrieve information from a db like so: <?php
I want to be able to retrieve a remote image from a webserver, resample
By using the function Date(ymdHis) i am able to retrieve the value of the
I'm trying to retrieve the last updated date from a cube. I have a
I am not able to retrieve records from Oracle based on multiple inputs. Here
I im having an issue with this, Im not able to retrieve data from
I want to be able to retrieve the date that a value was updated.

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.