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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:52:07+00:00 2026-06-13T18:52:07+00:00

I’ve searched through the posts for an answer and the closest answer came from

  • 0

I’ve searched through the posts for an answer and the closest answer came from the topic “trying-to-post-date-via-php-with-mysql-need-help”

I’ve got a form with 2 input fields and .The user selects the date from an html5 popup calendar picker, types in the time, and submits the form to a mysql db. I’m having trouble getting the date and time fields to validate/upload to the db.

In my MySQL db I have a table called appointments with a column called curdate that has a type of DATE; another column is called curtime with a type of TIME.

My PHP file has the PHP validation and SQL actions at the top of the file and the sticky html form at the bottom. The form uses to send the form

Here is the code:

$td = date( 'Y-m-d H:i:s', $phpdate );
$phpdate = strtotime( $td );
if(isset($_POST['submitted'])) {
    require_once('mysqli_connect.php');
    $errors=array();
if(empty($_POST['curdate'])) {
            $errors[]='Your date did not match';
        } else {
            $td=mysqli_real_escape_string($dbc,trim($_POST['curdate']));
    }

    if(empty($_POST['curtime'])) {
            $errors[]='Your time is empty';
    } else {
        $tt=$_POST['curtime'];
    }
if(empty($errors)) {
    $q="INSERT INTO users (first_name,last_name,email,curdate,curtime,physician,reason) VALUES ('$fn','$ln','$e','$td','$tt','$phys','$reason')";
    $r=@mysqli_query($dbc,$q);

    if($r) {
        echo '<h1>Thanks</h1>
        <p>You are now registered</p><p><br/></p>';
    } else {
        echo '<h1>System Error</h1>
        <p class="error">You could not be registered</p>';
        echo '<p>'.mysqli_error($dbc).'<br/><br/>Query:'.$q.'</p>';
    }

    mysqli_close();
    include('includes/footer.html');
    exit();
    } else {
    echo '<h1>Error</h1>
    <p class="error">The following errors occurred:<br/>';
    foreach ($errors as $msg) {
        echo "-$msg<br/>\n";
    }
    echo '</p><p> Please try again</p><p><br/></p>';
    }
    mysqli_close($dbc);
}
  • 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-13T18:52:08+00:00Added an answer on June 13, 2026 at 6:52 pm

    Mysql Or Mysqli Supports date format as ‘yyyy-mm-dd’ so u need to convert date and time in proper format before inserting in DB

    If you want to insert current date and time when the user submits the form then Use following Query

        INSERT INTO users (first_name,last_name,email,curdate,curtime,physician,reason) 
                   VALUES ('$fn','$ln','$e',CURDATE(),CURTIME(),'$phys','$reason')
    

    But if you want to insert date from form field then do following

        $td=$_POST['curdate'];
        $tt=$_POST['curtime'];
    
        $td=date('Y-m-d',strtotime($td));    //Converts date to 'yyyy-mm-dd' acceptable to mysql
        $tt=date('H:i:s',strtotime($tt));    //converts time to HH:mm:ss
    
        //Now apply Your Query as
         INSERT INTO users (first_name,last_name,email,curdate,curtime,physician,reason) 
                   VALUES ('$fn','$ln','$e','$td','$tt','$phys','$reason')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

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.