Jump to content

blank datefield or date showing 1969


jeff5656

Recommended Posts

SANITIZE get/post data BEFORE using them! NEVER (ever!) use get/post/cookie data without sanitize them before!

Don't trust your visitors, don't trust on what they are typing, don't trust on what they're not typing, don't trust nobody!

 

Assuming that your date column accepts NULL, you can make something like this (not exactly this, but just an example):

 

if (isset($_POST['stent_rev']) && function_to_validate_post_entry($_POST['stent_rev']))
{
    $stentrev = date("Y-m-d", strtotime($_POST['stent_rev']));
} else {
    $stentrev = '';
}

$sql = sprintf("INSERT INTO table (date_column) VALUES (%s)", (($stentrev) ? "'". $stentrev ."'" : "NULL"));
...
...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.