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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:51:50+00:00 2026-06-08T09:51:50+00:00

How can I insert the value from an (in a form) into a MySQL

  • 0

How can I insert the value from an (in a form) into a MySQL date field. I’m trying this:

<form  action="enviar.php" autocomplete="off" method="post"> 
    <label for="nacimiento" class="youpasswd" data-icon="p">
        Fecha de Nacimiento
    </label>
    <br>
    <input id="nacimiento" name="nacimiento"
           required type="datetime" placeholder="DD/MM/YYYY" />
</form>

enviar.php

$nacimiento= $_POST['nacimiento'];
mysql_query("INSERT INTO voluntarios(nacimiento) VALUES ('$nacimiento')");`

This is working for all the other fields but not with the date field; it is empty. What am I doing wrong?

Thank you

  • 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-08T09:51:52+00:00Added an answer on June 8, 2026 at 9:51 am

    You seem to have problems even getting the value from your input field to the server. This needs to get fixed first. Debug (var_dump) your $_POST data and check what is going on. Provide more code if you need more help. From what you write, I don’t see, why the value shouldn’t get sent.

    After you got your date string, convert the value to a string literal format MySQL recognizes:

    $mysqldate = date( 'Y-m-d H:i:s', $phpdate );
    

    Then insert it using mysqli_query:

    mysqli_query(sprintf("INSERT INTO voluntarios(nacimiento) VALUES ('%s')"),
                          mysql_real_escape_string($mysqldate));
    

    Using PDO do this:

    $dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
    $q = $dbh->prepare("INSERT INTO voluntarios(nacimiento) VALUE (:nacimiento)");
    $q->bindParam(':nacimiento', $mysqldate, PDO::PARAM_STR);
    $success = $q->execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this error when trying to insert data from a form into a
How can I insert a value from once cell into another cell from the
Why can't I insert DBNull.Value into a nullable image -field in sql server 2005?
i am trying to retrieve date from Mysql db to my html form in
I'm trying to insert variables from an SQL result into a HTML form in
How can i convert mysql results (from mysql_fetch_array) into such a form? $some =
I am trying to insert the value of this multiple checklist into the db
How can I insert a drop-down value into a DB? I have a form
I'm trying to insert information from a form into a database table and then
I have a question about inserting values into an input field from my MYSQL

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.