Forum Moderators: coopster & phranque

Message Too Old, No Replies

Form to datafile to HTML

I'm sure it's been asked before... but I really need help!

         

victoryrun

5:36 pm on Nov 17, 2003 (gmt 0)

10+ Year Member



I have a fairly large form (40+ fields) that need to be Posted to an HTML page. So far, I have one program that interprets all the fields and appends them to a .txt datafile. I'm not sure where to go from here. I need to find (or write?) a program that PULLS the info from the .txt datafile and displays it in HTML form. Can somebody help me do this, please? I am NOT a coder/scripter, and I'm lucky I've come this far (it's taken me forever).

The basic gist of this is USER comes to site, fills out form, clicks Submit button, and then gets a Thankyou page. (I've got all that done, for the most part.) The part I need help with is this -- ADMIN goes to (dfferent) page and views all submissions (sort of like online applications) in pretty HTML layout. This make sense?

My current script for writing to the .txt datafile is as follows:

sub write_form_info{
open (FORM, ">>$form_info_path") ¦¦ die ("I am sorry, but I was unable to open the file $form_info_path");
foreach $sortedkeys (@sortedkeys){
$sortedkeys =~ s/^\d*\)\s*//;
$sortedkeys =~ s/required-//;
($name, $answer) = split (/\¦/, $sortedkeys);
print FORM "$answer¦\n";
}
print FORM "\n";
close (FORM);
}

And the way the datafile is displayed is like this:

name¦
fieldone¦
email@addy.com¦
fieldtwohuge¦

etc.

What do I need to do to get it to display as:

name¦fieldone¦email@addy.com¦fieldtwohuge

And once I get to that stage, what sort of file would pull these fields into an HTML page? Thanks for the help!

Thanks so much!

moltar

6:17 am on Nov 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



print FORM "$answer¦\n";

remove the \n from the end, that will get rid of the new lines ;)

read from file:


print "<html><head><title></title></head><body>\n";

open(FILE, "< filename.txt") or die "cannot open filename.txt";
while (<FILE>) {

my ($name, $fieldone, $email, fieldtwo) = split(/\¦/);
print "$name, $fieldone, $email, fieldtwo<br>\n";

}
close(FILE) or die "cannot open filename.txt";

print "</body></html>";

anallawalla

1:08 pm on Dec 7, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



victoryrun,

If you still need a good script, I can send you one I downloaded many years ago. The users see just the form but the admin sees the form (to add entries manually) plus the received data in a table.

Sticky me if you want it.

Ash