Assigning PHP values to hidden fields

wcsconcierge 01 Jun, 2008
This project of mine is forcing me to dust off a lot of PHP skills I haven't had to use in a long time. Can someone tell me what's wrong, with this line:


<input type="hidden" name="lastupdated" value="<? php date('m-d-y')?>" >


It's probably obvious but, I'm not seeing it. Thanks in advance!
GreyHead 02 Jun, 2008
Hi wcsconcierge,

The space between <? and php and you need an echo toshow the date results
<input type="hidden" name="lastupdated" value="<?php echo date('m-d-y'); ?>" />
Bob
Savant 12 Jun, 2008
This - only a little shorter - version should also work:


<input type="hidden" name="lastupdated" value="<?= date('m-d-y'); ?>" />


Only for "i-need-every-bit" junkies. In my opinion Bob's Code is better to read/understand for everyone. Depends on individual taste, i guess.🙂
GreyHead 12 Jun, 2008
Hi Savant,

Yes that will work perfectly. (As you deduced I try to use 'full' code here to avoid confusion for newbie users.)

Bob

PS I think you can leave out the ';' too :-)
This topic is locked and no more replies can be posted.