Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How to create a hidden field variable from an echoed PHP figure?

How to create a hidden field variable from an echoed PHP figure?

11:47 pm on Oct 7, 2007 (gmt 0)

New User

10+ Year Member

joined:Apr 2, 2005
posts: 11
votes: 0


I have a PHP script on a shopping cart summary page that creates an invoice number and then echoes it to the page. This page, when submitted, will go to the shopping cart processor.

The echo portion of the script is working properly, it generates the number as intended.

My problem is that, not being very experienced in PHP, I want the invoice number not only echoed (which it is doing properly now), but also to populate a value in a hidden field that is submitted to the shopping cart processing page. My question is how do I populate the hidden field with the figure that is now being echoed in the script below?

The script that generates and echoes the invoice number is as follows:


echo "SA"; //department code
echo date ("mdy"); //date generator

// begin counter this reads figure from "count_file.txt"

if (file_exists('count_file.txt'))
$fil = fopen('count_file.txt', r);
$dat = fread($fil, filesize('count_file.txt'));
echo $dat+1;
$fil = fopen('count_file.txt', w);
fwrite($fil, $dat+1);

$fil = fopen('count_file.txt', w);
fwrite($fil, 1);
echo '1';
// end counter


The hidden field is as follows:

<input name="Invoice_Num" type="hidden" id="Invoice_Num" value=" ">

I would like the value in the above to reflect the invoice number that is echoed by the above PHP script.

Any insight into how to accomplish this is greatly appreciated.

Thanks in advance for any help you can give me on this.


1:51 am on Oct 8, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 27, 2005
votes: 0

<input name="Invoice_Num" type="hidden" id="Invoice_Num" value="<?=$dat+1;?>">


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members