Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do redirection

Status
Not open for further replies.

thameema

Programmer
Jan 30, 2001
30
US
hi all,
I have a form. If i click submit it should handle one cgi script. there i m checking a condition.. if that is true it should execute the rest of the page and give output else it should redirected to another cgi page which will process the request. How to do this?
 
Hello tham,
here is a rough overview of one way to do it......

#!/usr/local/bin/perl
use CGI;
my $cgi = new CGI;
$condition = $cgi->param('condition');

unless ($condition)
{
print $cgi->redirect(-uri=>' -nph=>1);
}

# if we did not just go to someserver.com/somepage.html,
# condition existed or was true.

# continue with execution here.



'hope this helps.


keep the rudder amid ship and beware the odd typo
 
One more detail,
you may not need the -nph=>1 if you are not using IIS or another web server that expects non-parse-headers. You do not need it with Apache.

Good Luck,


keep the rudder amid ship and beware the odd typo
 
I don' think that code will quite work. Just printing the redirect shouldn't immediately end the perl program. You should probably also have an "exit" statement after the redirect. It wouldn't hurt in any case.

There may be another problem too. From your description, tt sounds as if you don't want to go to another html page, but to another cgi script that will process the data. In that case you would need to redirect to something like:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top