homepage Welcome to WebmasterWorld Guest from 54.161.133.166
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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




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

Greetings,

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:

<?php

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;
fclose($fil);
$fil = fopen('count_file.txt', w);
fwrite($fil, $dat+1);
}

else
{
$fil = fopen('count_file.txt', w);
fwrite($fil, 1);
echo '1';
fclose($fil);
}
// 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.

Scott

 

Steerpike




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved