If you just want it to go into the database table, why bother putting it into the form as a hidden variable? Just create a column for it, and have it default to the current date/time if nothing is entered (which it won’t be if you don’t have a form field for it).
The issue there is that there are other forms which update other fields, so wouldn’t want this field to update to the current date when they are submitted.
If you set the database column to default to current date, it will not update the date field unless you give it a date to update with. If you don’t provide the date for that column, it won’t UPDATE. But it will enter the current date for an INSERT.
So how would I give it the date? It must be close, as the code above gets the day and month right, but gets the year wrong.
I know you can use TIMESTAMP to do this, but I am already using that for a LastUpdated field. And I thought mySQL only lets you use one of those in a table?
I’m confused. You’re asking how to give it a date for UPDATE; but in post #3, you indicate that you DO NOT want it to update the date field:
If you do not want the date field to update to anything during an UPDATE, don’t supply the date and don’t refer to it in the column names of the UPDATE tableName portion. If you DO want the date updated, supply the date in the same format as the database natively formats it. (ie, if the database formats dates as “yyyy/mm/dd”, then supply the date as 2015/07/08. If the database formats as dd-mmm-yy, then supply the date as 08-JUL-15; then refer to the column in the UPDATE tableName portion, as well as provide the date in the SET section.)
UPDATE tableName
SET id='{id}', name='{name}', date='{properFormattedDate}'
WHERE something = {something}
UPDATE tableName
SET id='{id}', name='{name}' /* don't supply date */
WHERE something = {something}
And two UPDATE forms, one where all the Lodge info can be updated, and I use a TIMESTAMP field to record the date of that change.
And a second UPDATE form where someone can just tick a box to record that they are registering the lodge to (to appear on the website). And we would like to record the date they do that.
So I was just saying that I didn’t want the 2016_Registered_Date field to default to the current date any time the record is updated, because then it would update when either of those forms is submitted.
Which is why I was looking at using a hidden field in the registration form.
It looks like it works when I changed the date format, so changing:
<input name="2016_Registered_Date" type="hidden" value="<?php echo date('j F Y');?>" >
If you have the date created at the time of the form creation and send it to the user as a hidden field in the form, then the user could relatively easily change the value of the hidden field in the form and thus falsify their registration date. Not sure if it is really important, but the chance is there.