Page 1 of 1

how do i put the date into my HTML form ?

Posted: Wed Nov 26, 2003 8:15 pm
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

Posted: Wed Nov 26, 2003 8:46 pm
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

Posted: Wed Nov 26, 2003 10:03 pm
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.