PDA

View Full Version : Newbie's problem with Location?


compassman
08-04-2006, 10:29 PM
I have this CGI script which isn't working quite right:


#!/usr/bin/perl -w
open (OUTPUT, ">>db.txt")|| die "cannot open: $!";
$cgi_arg = $ENV{'QUERY_STRING'};
print OUTPUT $cgi_arg;
print OUTPUT "\n";
close (OUTPUT);
print "Location: http://mysite.here.com/results.html\n\n";


The routine does collect the data and outputs it to the file. It also calls the file at the end of the script, but there is a problem. The displayed results are not correct unless I refresh the page. Then the numbers are correct. Is there a problem with the way I am calling the results files?

rwedge
08-05-2006, 10:16 PM
The html page is most likely cached by the browser. You can add a random string to the end of the URL to force the browser to get a fresh copy. -- results.html?84753094

my ($i, $num);
my @ext = (1 .. 9);
for ($i = 1;$i < 9; $i++) { $num .= $ext[rand @ext]; }

print "Location: http://mysite.here.com/results.html?$num\n\n";

compassman
08-09-2006, 03:42 PM
Your advise was on target. Thanks.:thumbsup: