2
votes

I have a Perl CGI script that creates a login screen, i.e. user name and password.

I want, after successful login, the user to be redirected to the next action within the application (another Perl CGI script).

What is the command to redirect one CGI script or to an HTML page?

2

2 Answers

4
votes

An example using CGI as David Dorward mentions.

use CGI;

if (redirect_needed) {
    # If redirect is desired, don't print headers...
    print CGI->redirect("http://some.other.url/");
    exit; 
}

# If no redirect is desired...
print CGI->header();
# etc...
5
votes

In HTTP terms you should have your program output a 302 or 303 status code and a Location header.

If you are using CGI.pm then you can use the redirect method to achieve this.