Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to do redirection

How to do redirection

How to do redirection

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?

RE: How to do redirection

Hello tham,
here is a rough overview of one way to do it......

use CGI;
my $cgi = new CGI;
$condition = $cgi->param('condition');

unless ($condition)
print $cgi->redirect(-uri=>'http://someserver.com/somepage.html', -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

RE: How to do redirection

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

RE: How to do redirection

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:


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close