auto redirect

hi experts,
after a user filled in my form, i always show him the filled information and ask him to click back:

my code:

print <<HEADER;
<html>
<head>
<title>
Question
</title>
</head>

<BODY background=/server.gif bgcolor="#ffffff"
  text="#000066" links="#000099" vlink="#000099" alink="#660099">

<br clear=all>

<br><code>
<p>$name, thank you for sharing your opinion with us on the subject $title. <br>

<p>You may go back and see the updated database on the disscusion list by clicking the LIST button</p>
<a href="http://www.eee.hku.hk/~lhui/titles.html">LIST</a>
<br>

</code>
</body>
</html>
HEADER


now I would like to change it to that
after showing his information, it will automatically load to the destination page.
how can i do that?

Thanks,

mwhuen
mwhuenAsked:
Who is Participating?
 
ndnetConnect With a Mentor Commented:
this little chunk of code is one i've found handy. It's on C-Net. It uses the best possible redirect on a per-browser basis, and degrades gracefully.


ex)

<HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("http://www.yourserver.com/dir/file.ext");
//-->
</SCRIPT>
<NOSCRIPT>
<META http-equiv="Refresh" content="0; URL=http://www.yourserver.com/dir/file.ext">
</NOSCRIPT>
</HEAD>

Just add a link in the body and you're done.

However, this could also be done with SSI, just include the page in:

ex)

<\!--\#include virtual=\"\/myndnet\/dir.txt\" -->

This will work on any non-excutable, non-binary file.

0
 
ozoCommented:
<head><META HTTP-EQUIV="REFRESH" CONTENT="5" URL="http://www.eee.hku.hk/~lhui/titles.html">
0
 
maneshrCommented:
you can do it in one of the foll ways.

you can wait for some time and show a message to the user and then redirect to the other site (comment line 12 and uncomment line 8 and 9)

or you can just directly throw the user to the site
(uncomment line 12 and comment lines 8 and 9)

  +1   #!/usr/local/bin/perl
    +2
    +3   use CGI;
    +4
    +5   $query=new CGI;
    +6
    +7   if ($query->param){  ## The form has been submitted by user
    +8      #print "Content-type: text/html\n\n";
    +9      #print "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"5; URL=\http://www.e
ee.hku.hk/~lhui/titles.html\">";
   +10
   +11      ## OR you do directly throw the user to a seperate URL
   +12      print "Location: http://www.eee.hku.hk/~lhui/titles.html\n\n";
   +13      exit;
   +14   }
   +15
   +16   print "Content-type: text/html\n\n";
   +17   print "<FORM ACTION=\"".$ENV{SCRIPT_NAME}."\"METHOD=POST>\n";
   +18   print "Enter anything in the text box: <INPUT TYPE=TEXT NAME=text_mess
age VALUE=\"\">\n";
   +19   print "<P><INPUT TYPE=SUBMIT VALUE=\"Submit Now!!\">\n";
   +20
   +21   print "</FORM>\n";
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
mwhuenAuthor Commented:

In fact, the code I listed in my question is from my cgi file.
In the cgi program, I want to show
"
<html>
<head>
<title>
Question
</title>
</head>
<BODY background=/server.gif bgcolor="#ffffff"
  text="#000066" links="#000099" vlink="#000099" alink="#660099">
<br clear=all>
<br><code>
<p>$name, thank you for sharing your opinion with us on the subject $title. <br>
</code>
</body>
</html>
"

and after the user read this for 5 seconds, the brower will automatically redirect to another page, the LIST.html.

I have tried the ozo's method:

<head><META HTTP-EQUIV="REFRESH" CONTENT="5" URL="http://www.eee.hku.hk/~lhui/titles.html">
but after 5 seconds, it shows:
"I don't understand the Content-type."

I guess my cgi program may restart again, and check Content-type.

Why?
Please help!!!
:)

Thank
0
 
maneshrCommented:
try with the URL= within the content attribute...

<META HTTP-EQUIV="REFRESH" CONTENT="5; URL=http://www.eee.hku.hk/~lhui/titles.html">
0
 
mwhuenAuthor Commented:
yes, it works now, thank you all guys.
:)
0
All Courses

From novice to tech pro — start learning today.