in reply to Perl/CGI redirect.
The text I am using to learn CGI isn't particularly good. ( i.e. many demos, few explanations ).It was quite some time since I looked at it, but I think that this tutorial by Ovid looked excellent if you want to learn CGI with perl - and moreover, in a clean and secure way too.
Also, if you want to see a little more what happens behind the scenes of a normal header and a redirect, just try this silly little program on the command line (not on the web server):
Those are the texts that your script sends to the web browser to tell it what is happening, and what it should do. Either one of these should come first in your script (unless you are doing some by hand manipulation of the headers) and they are not possible to combine. Since you use CGI.pm anyways, might as well use the header function too, instead of printing "Content-type..." by yourself. That way you will not have any spelling errors, and CGI.pm will see to it that it works even on half-broken servers. :)#!/usr/bin/perl -w use strict; use CGI; my $q = CGI->new; print "This is the redirect header:\n"; print $q->redirect('/login.html'); print "And this is the normal header:\n"; print $q->header; print "And this is an alternative header:\n"; print $q->header('text/plain');
|
|---|