Jerry Kassebaum wrote:
> The following cgi script is at http://biblescramble.com/ezo7x.cgi.
>
> The first time you load this page it will set a cookie on your machine and
> display the error message in the last line of the script.
>
> The next time(s) you load it it will redirect to the html page it creates on
> the server.
>
> If you delete the cookie it will go back to the error message.
>
> How do I set the cookie and redirect in one pass???
#!/usr/bin/perl
use strict;
use warnings;
use CGI ":standard";
my $html = "<html><head><title>Bible Scramble Game</title></head><body>Desired
page</body></html>";
# not sure why you don't just return the HTML instead of writing to file
open J, ">biblescramble7.html";
print J $html;
close J;
my $plays; # added - but has no function
if (defined cookie('guest')) {
$plays++; # has no function
# not sure what you want to do when the cookie is already set
# vs not set
} else {
# Missing newline on line below - added
print "Set-Cookie: guest=218; expires=Wed, 29-Dec-2022 00:00:00 GMT\n";
}
# in either case you end up at the same place
print "Location: http://biblescramble.com/biblescramble7.html\n\n";
__END__
> #!/usr/bin/perl
>
> use CGI ":standard";
>
>
> ############### Print the HTML/JavaScript page to disk
>
>
> $html="<html><head><title>Bible Scramble
> Game</title><script></script></head><body>Desired page</body></html>";
>
>
> open(J, ">biblescramble7.html");
> print J $html;
> close J;
>
> if(defined cookie('guest')) {
> $plays++;
> }
>
>
> else {
> print "Set-Cookie: guest=218; expires=Wed, 29-Dec-2022 00:00:00 GMT";
> }
>
>
>
> print "Location: http://biblescramble.com/biblescramble7.html\n\n";
>
> print "Bug! Press refresh button or just try again to play game. (Sorry. I'm
> working on it!)\n\n";
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs