in reply to a big mess... (.cgi / frames question)
This code does not stack up the frames like yours does. Just save it as your fram.cgi and call it from you web browser. It worked for me. The path_info routing I found extremely useful when generating frames form a perl script, and I found it in the CGI.pm manual. You should probably upgrade this to use CGI.pm, it is much easier.#!/acclib/perl5/bin/perl my $path = $ENV{'PATH_INFO'}; my $file = 'coord.dat'; # Name the file print "Content-type: text/html\n\n"; #if no path print the frameset if( $path !~ /\S/ ) { print_frameset(); } #if script called with "/entry" appended then print the #left frame and parse the posted data elsif( $path =~ /entry/ ) { parse_form(); print_entry(); } #if script called with "/coord" appended then print the #right frame elsif( $path =~ /coord/ ) { print_coord(); } exit; sub parse_form { $buffer = 0; read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); # needed to convert from HTML receive foreach $pair (@pairs) { ($name, $value) = split(/=/,$pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $FORM{$name} = $value; } #print data to file only if both fields were populated if( $FORM{'source'} =~ /\S/ && $FORM{'dest'} =~ /\S/ ) { open(FILE, ">>$file" ) || die; # Open the file for writing ( +append) print FILE "$FORM{source} - $FORM{dest}\n"; close FILE; } } sub print_frameset { print "<html>\n <head>\n"; print "<title>Match Results Thus Far</title>\n</head>\n"; print "<FRAMESET COLS=\"500,*\">\n"; print "<FRAME SRC=\"$ENV{'SCRIPT_NAME'}/entry\" NAME=\"left\" NORE +SIZE>\n"; print "<FRAME SRC=\"$ENV{'SCRIPT_NAME'}/coord\" NAME=\"right\" NOR +ESIZE>\n"; print "</FRAMESET>\n"; print "<body>\n"; print "<hr size=5 width=90%>\n"; print "<ul>\n"; print "\n$buffer\n"; print "<p>Script written by Neil Gaffin\n"; print "</body> </html>\n"; } sub print_coord { print "<html>\n <head>\n"; print "<title>Match Results Thus Far</title>\n"; print "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"5\" URL=\"$ENV{'SCRIPT_NAME'}/coord\" TARGET=\"right\">\n</head>\n"; print "<body>\n<h5>\n"; $lc = 0; open FILE, "$file"; my @lines = <FILE>; close FILE; while (@lines) { $lc += 1; print "<center> $lc -- $lines[0] </center>\n"; shift (@lines); } print "</h5>\n"; print "</body> </html>\n"; } sub print_entry { print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"; print "<html>\n <head>\n"; print "<title>Neil's Script - Search Engine</title>\n</head>\n"; print "<body bgcolor=#FFFFFF text=#000000> <center>\n"; print "<h2>Move Database Page - File I/O</h2>\n </center>\n"; print "Use the form below to enter moves<br> \n"; print "Enter moves in format:<p>\n"; print "Source Space: Row,Col<br>\n"; print "Dest Space: Row,Col<p>\n"; print "Example: A8, H1, C5, G3<br>\n"; print "(Row must be A-H, Col must be 1-8<p>\n"; print "<hr size=7 width=90%><p>\n"; print "<FORM Action=\"$ENV{'SCRIPT_NAME'}/entry\" METHOD=\"POST\" target = \"left\" >\n"; print "<center><table border>\n <tr>"; print "<td>Source Space: </td><td> <input type=text name=\"source\" size=4><br></td>\n </tr><t +r>\n"; print "<td>Destination Space: </td><td> <input type=text name=\"dest\" size=4><br></td>\n </tr><tr>\ +n"; print "<th colspan=2><input type=submit value=\"Done!\"> <input type=reset><br></th>\n"; print "</tr></table></center></form>\n"; print "<hr size=7 width=90%><p>\n </body></html>\n"; }
|
|---|