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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect

Status
Not open for further replies.

zfang

Programmer
Apr 3, 2002
23
US
Hi:

I have a problem related to redirect. Here is the senario:

There are 2 perl scripts: A.cgi,B.cgi, which are located in two different servers.
1) A user fills a form
2)A.cgi process the form and redirects to B.cgi with passing parameters. It's required that the browse displays a message like "In processing" before B.cgi finishes proceessing and redirects back to A.cgi.

Following is the script doing display message and redirect:

use CGI qw/:standard/;
my $q = new CGI;
#
#doing sth processing the form
#
print header("text/html");
print "In processing...";
my $url = "$q->redirect($url);

However, this script doesn;t work as expected, because the
line

print header("tect/html");

is before the line

$q->redirect($url);

If I rearrange them as

my $url = "$q->redirect($url);
print header("text/html");
print "In processing...";

I will not get the message "In processing..." printed out when B.cgi is processing.

Could anyone give me advice how to solve this problem?.

Thanks

George
 
can you use javascript to display message "in processing"?
 
That is becuase that the CGI module will not redirect when a html header is created. Try "perldoc CGI" and read more about it.

Hope this helps.
 
scoon:

Thanks.
I know it will not direct when a html header is created. But is there a way to solve my problem.
 
Try using a meta redirect instead, like this:
Code:
$url = "[URL unfurl="true"]http://www.bydisn.com";[/URL]
$pause = 2; # 2 seconds
print <<END;
<html>
<head>
<meta http-equiv=&quot;refresh&quot; content=&quot;$pause;URL=$url&quot;>
<title>REDIRECT</title>
</head>
<body>
<h1>REDIRECT</h1>
</body>
</html>
END
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Tracy:

Thanks for your suggestion. I guess your code will redirect to B.cgi if set $url=&quot;after the message &quot;REDIRECT&quot; is shown for 2 seconds. However, no message is displayed when B.cgi is processing, right? How can a message be displayed when B.cgi is processing?

George
 
I would do that with javascript, before you call the cgi program. Thread215-152691 shows one way to create a flashing &quot;working&quot; message. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Tracy:

Thank you very much. It works pretty good.

George
 
You're welcome. Glad to be of assistance. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top