PDA

View Full Version : Evaluate Hashes


buzzbuzz
11-10-2002, 01:41 PM
Here's the situation:

I have a multipage form script that basically just moves the user from page 1 to the last page in a form while using hidden to save all the form variables while it goes along. When the user hits submit it goes to a thankyou page as well as sending off an email to a certain address.

Now the problem...

This is a 200+ field form, and the receiver wants the data completely formatted in html in their email. Fine...did that, but the HTML for this part is extremely long, and I don't want to include it in the actual program (as I have several different forms to use this multipage form script with)...making it extremely large.

I want to read in the HTML that will be sent in the email. I cannot figure out how to evaluate a hash in a file that is read in. I can do it with a normal string variable :

$line =~ s/(\$\w+)/$1/eeg;

but cannot figure out how to read in a file and evaluate the hashes in it. I've already tried saving a hash value into just a key variable ... didn't work either.

If anyone out there has ANY suggestions it would truly be appreciated!

Thanks in advance...

mercurus
11-11-2002, 05:57 AM
G'day

A few thoughts...

1a) Keep the HTML in the script... only have printing it called via a subroutine. That way, you can just alter the content of the subroutine and keep going.
That's probably not what you're looking for though...

1b) write out the html into a file with the variables included as the script executes (eg. for each 'page' of the forms) and then either read the HTML file into the email or attach it to an email.

2) Investigate the possiblity of an HTML template using CGI.pm
This might allow you a bit more freedom...

3) There might be a rexeg that'll allow it, but I can't imagine it...

I think probably 1b is your best bet.

How it would work:
1 - Print out the first form.
2 - Receive the input and write this out in html to an external file.
3 - Print out the second form.
4 - Recevie the input and update the file created in step two to add in the new text.
5 - Repeat for however many fields and form pages you have.
6. Add in the closing HTML.
7. Now you can read the external file into an email (with a LOT of input validation!!!) and email it away OR attach the external file to the email.
8. Send the email

(you can even name the external file with the username or a key field so that you can keep a record of who has filled in what and when.)

Just my $0.02

Cheers
mercurus