how do i put the date into my HTML form ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gbruit
Forum Newbie
Posts: 4
Joined: Wed Nov 26, 2003 8:15 pm

how do i put the date into my HTML form ?

Post by gbruit »

I'm making a form in HTML.
I need a hidden .. where i put the current date and a hidden .. with a customernumber (maybe just a random number)
I tried something like this but that does'nt work .... (yes i'm new here ;)


head, body, form and then .......

<input type="hidden" name="command" value="CRAUTH"
<input type="hidden" name="service_id" value="00"


<?php

$today_date = date("YmdHis") ;
$refnumber = mt_rand() ;
echo"<input type="hidden" name="ref_no" value="$refnumber"" ;
echo"<input type="hidden" name="ref_date" value="$today_date"" ;

?>

..... etcetera

Pse help.

(email me directly: gbruit >at< yahoo >dot< com)
gb
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

instead of this :

Code: Select all

<?php 

$today_date = date("YmdHis") ; 
$refnumber = mt_rand() ; 
echo"<input type="hidden" name="ref_no" value="$refnumber"" ; 
echo"<input type="hidden" name="ref_date" value="$today_date"" ; 

?>

try this :

Code: Select all

<?php 

$today_date = date("Ymd H:i:s") ; 
$refnumber = mt_rand() ; 
echo '<input type="hidden" name="ref_no" value="'.$refnumber.'"'; 
echo '<input type="hidden" name="ref_date" value="'.$today_date.'"' ; 

?>
edit: please note that I just added the space in the time and the :'s so that it would format it in an easier way. the main thing was how you was echoing out your code, which i corrected. just compare it to your original to see what I did differently.

http://www.php.net/echo
gbruit
Forum Newbie
Posts: 4
Joined: Wed Nov 26, 2003 8:15 pm

Post by gbruit »

Yep it works now.
Tnx
(http://www.php.net/echo said " instead of ')
I didn't know about the .$var. (what's the meaning of that, oh well I find out myself) Thanks again.
Post Reply