如何从一个CGI重定向到另一个 [英] How to redirect from one CGI to another
问题描述
我正在将数据从 A.cgi
发送到 B.cgi
。 B.cgi
更新数据库中的数据,并应该重定向回 A.cgi
,此时 A.cgi
应该显示更新的数据。我在数据库更新后立即将以下代码添加到 B.cgi
进行重定向:
I am sending data from A.cgi
to B.cgi
. B.cgi
updates the data in the database and is supposed to redirect back to A.cgi
, at which point A.cgi
should display the updated data. I added the following code to B.cgi
to do the redirect, immediately after the database update:
$url = "http://Travel/cgi-bin/A.cgi/";
print "Location: $url\n\n";
exit();
成功更新数据库后,页面仅打印
After successfully updating the database, the page simply prints
Location: http://Travel/cgi-bin/A.cgi/
并停留在 B.cgi
上,而从未重定向到 A.cgi
。如何使重定向有效?
and stays on B.cgi
, without ever getting redirected to A.cgi
. How can I make the redirect work?
推荐答案
位置:
是标头和标头必须位于所有普通输出之前,这可能是您的问题。但是无论如何,手动进行此操作不必要地复杂,您最好使用重定向CGI.pm的功能
Location:
is a header and headers must come before all ordinary output, that's probably your problem. But doing this manually is unneccessarly complicated anyways, you would be better of using the redirect function of CGI.pm
这篇关于如何从一个CGI重定向到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!