Hi Folks,
I looked around and couldn't quite find a solution that fits my problem. I have an archaic script that needs some updating (no budget to bring it up to spec and the way it should be!). Anyway, I have a script to write to a log file and another one to display the logfile in a nice HTML table.
Problem: They now wish to EDIT records in this flatfile from the HTML output page and I'm stuck. There is no admin support and I can't add any mods, so this is old school.
GOAL: I want to open the form I got the data from in the first page to launch pre-populated with the record the user clicks on (say the click "edit record 5", then the form would open pre-populated with the variables from the 6th entry in the flatfile; per n-1). From here, the user could "edit" the form and re-submit it as a new record.
Hopefully this snippet will give an idea:
#!/usr/bin/perl
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
open(OUTFILE, ">results.html") or die "Can't write to result.html: $!\
+n";
print OUTFILE "<html><head>";
print OUTFILE "<title>Results: External</title>";
print OUTFILE "</head>";
print OUTFILE "<body>";
print OUTFILE "<table border='1'>";
print OUTFILE "<tr class='light'>";
print OUTFILE "<td>1</td>";
print OUTFILE "<td>2</td>";
print OUTFILE "<td>3</td>";
print OUTFILE "<td>4</td>";
print OUTFILE "</tr>";
open (DB,"ext.log") or die("There was a problem opening the file.");
while ($entry=<DB>) {
@fields=split(/ /,$entry);
print OUTFILE "<tr>";
print OUTFILE "<td><a href=\"/path/to/form.html">Edit Record</a></td>"
+;
print OUTFILE "<td>$fields[0]</td>";
print OUTFILE "<td>$fields[1]</td>";
print OUTFILE "<td>$fields[2]</td>";
print OUTFILE "<td>$fields[3]</td>";
print OUTFILE "</tr>";
}
close DB;
print OUTFILE "</table>";
print OUTFILE "</body>";
print OUTFILE "</html>";
close OUTFILE;
Can anyone help me? I not a terribly strong coder, so bare with me. Thank you all!
lakeTrout
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.