Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Can anyone help. I`ve got a University project due to be submitted in a couple of weeks and I am totally stuck. I am creating an online booking system and half the pages are written in HTML and half are CGI generated pages. I`ve got a login page where the password is checked by a script but I then need to redirect to an HTML page. Can this be done without a link?

Replies are listed 'Best First'.
Re: perl cgi html and redirection
by voyager (Friar) on Apr 11, 2001 at 03:50 UTC
    use CGI; my $q = CGI::new; # you may want to keep login info my $session = {userid = "something", etc}; my $c = $q->cookie(-name => 'session', -value => $session); print $q->redirect(-uri => 'somepage.html', -cookie => $c);
Re: perl cgi html and redirection
by nysus (Parson) on Apr 11, 2001 at 08:42 UTC
    Also keep in mind that the javascript solution is considered bad design since some people may have javascript turned off, resulting in a lost sale and no money.

    If you're looking for a simple solution, have the script generates an exact copy of the html page you want users to get to after the correct password is given. Not ideal, but simple.

Re: perl cgi html and redirection
by iamcal (Friar) on Apr 11, 2001 at 15:00 UTC
    If you don't want the overhead of loading a module:

    print "location: mypage.html\n\n";
Re: perl cgi html and redirection
by Anonymous Monk on Apr 11, 2001 at 04:19 UTC
    think I found a really simple solution, although I still have to try it out under apache and perl, only tried it with IE on the windows Desktop.
    JavaScript:
    <!-- window.location.replace("url"); -->
    Thanks for your help
      Not a good idea. You have just sent, in plain text for the world to see, the url of where people get to once they passed the user id / password validation. Remember that everything your web server sends to the client's browser is completely visible to that person - check out the "view source" option.
      Unless you are checking the password in Javascript on the client (don't), this won't help you.

      User types in id/pw and clicks button. Server validates password (I presume). The server has to do something now ... like the redirect.

      You certainly don't want to send back a page saying "Your password was ok; click here to continue"