CGI redirect method opens new browser window

P

Patrick Hartman

Hi, I am creating a login form that redirects the user to a different
page after they are authenticated. It is redirecting them, always
opens up the new page in a seperate browser window/tab and leaves the
login form open.

I was hoping to have it perform the redirect in the same browser
window that they are using to login. Is this possible?

#!/usr/bin/perl -w
use strict;
use CGI;

# make cgi object
my $cgi = CGI->new;

# if the page was posted
if ($ENV{'REQUEST_METHOD'} eq 'POST')
{
# form data we will authenticate
my ($username,$password) = ($cgi->param('username'),$cgi-
param('password'));

# ... do that ...

# redirect them where they need to go
print $cgi->redirect(-uri => 'http://localhost/stats/sales-
comparison', -status => 301);

}


I also tried doing it without CGI by just sending a location header,
but that did the same thing:

#!/usr/bin/perl -w
use strict;

# if the page was posted
if ($ENV{'REQUEST_METHOD'} eq 'POST')
{
# form data we will authenticate
my ($username,$password) = ($cgi->param('username'),$cgi-
param('password'));

# ... do that ...

# redirect them where they need to go
print "Location: http://localhost/stats/sales-comparison\n\n";

}

Any suggestions or tips would be appreciated.

Patrick
 
P

Patrick Hartman

Please disregard, the problem was due to a typo in my HTML form code.
Sorry about that.

Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top