in reply to how to move to new page on successful login

The redirect has to go in the HTTP header, so you would use it instead of print $q->header(...). This means that you have to defer printing the header (or redirection) until after you've checked the user's login info.

Replies are listed 'Best First'.
Re^2: how to move to new page on successful login
by arnieboy (Initiate) on Feb 25, 2008 at 20:52 UTC
    Hi pcc88mxer, Thanks a lot for the reply. I do not quite understand how to defer printing the header after I have checked the user info. Could you kindly elaborate? Without the header at the beginning (before the HTML block), the server is throwing an error and the page is not being created. How do I make the redirect go to HTTP header (so that I can use it instead of q->header(...))? I am sorry.. but I am really new to all this. Thanks and regards, Ken
      You'll either do the redirect or you print the header and emit an HTML page:

      use CGI; ... $q = new CGI; my $login_ok = check_login($q); if ($login_ok) { $q->redirect(...); } else { $q->header(...); # emit html page }

      Move the code that checks for the user's credentials before the code that prints anything.