Validation of Primary Key Datetime variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I wonder if anyone can help.

I have designed a newsblog which uses PHP and MySQL. Each news story has
a primary key which is the current date. The datatype used in MySQL is
"datetime". When stories are extracted from the database the user can
then navigate based on date order. 

When a user adds a news story to the database the current days date is
shown in the form using 

<dt>
<label for="publish_date"><?php echo $publish_datelabel ?></label></dt>
<dd><input type="text" name="publish_date" id="publish_date"
value="<?php echo date('Y-m-d H:i:s') ?>"/></dd>


This is the date added to the DB by default. 

However, the user must be able to change the date so that they can set a
date sometime in the future when they want the story to be published.
The only stories shown in the archive (and pulled through to the home
page) are those which are before or on today's date.

My problem is that I am not sure how to validate any changes made to the
$publish_date so that it will conform to the required datetime range in
MySQL and not give the useless answer 0000:00:00 00:00:00.

Does anyone know how to do this?
Thanks

Steven Price 




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux