Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Need HTML Redirect

by Tii (Monk)
on Sep 29, 2000 at 00:03 UTC ( [id://34476]=perlquestion: print w/replies, xml ) Need Help??

Tii has asked for the wisdom of the Perl Monks concerning the following question:

Greetings,

I'm trying to use a Perl script to print some redirect HTML after processing a form.

When I use the following code:

print <<"EOF"; <HTML> <HEAD> <META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=http://my.url.com/page.html\"> </HEAD><BODY></BODY> EOF print end_html;

The page doesn't redirect, but just spits out my HTML. The result page literally looks like this:

<HEAD> <META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://my.url.com/page.html"> </HEAD><BODY></BODY> </BODY></HTML>

(I used my.url.com just for this example.) I've also tried printing "Content-type: text/html" but that didn't make any difference. BTW: I'm also using CGI.pm.

Can someone shed some light on this?

Gratefully,
Tii

Replies are listed 'Best First'.
Re: Need HTML Redirect
by Fastolfe (Vicar) on Sep 29, 2000 at 00:07 UTC
    I can't tell if you're adding the line break after the 0; or if that's how your page actually is. There should be no break here.

    Consider using CGI.pm's redirect method to perform your redirection for you. This will do an HTTP redirection and won't rely on putting things in HTML to do it for you. It's also much cleaner and will not muck up the Back button's behavior.

    Also, if you were to use 'EoF', you would not have to escape your double-quotes. Think of the quotes around your EoF as the type of quotes around the rest of your text.

      Thanks!
      I'm new to CGI.pm and had never used its redirect capability before.

      Thanks again,
      Tii

Re: Need HTML Redirect
by le (Friar) on Sep 29, 2000 at 00:07 UTC
    If you're already using CGI.pm, why not take what it has?
    print $q->redirect("http://some.place.org/");
Re: Need HTML Redirect
by arturo (Vicar) on Sep 29, 2000 at 00:10 UTC

    My guess is that you may have missed the newlines on the Content-type line:

    print "Content-type: text/html\n\n";
    You might also consider using a simpler redirect of the form,
    #!/usr/bin/perl print "Location : new-url\n\n"; exit;
    HTH

    Philosophy can be made out of anything -- or less

      I'll take the latter.

      It turns out that my web space provider has a problem with their Apache module and it gives me errors when I try to use CGI.pm's redirect. Printing the location works perfectly.

      Thank you very much!

      And thanks, merlyn, for the correction. =)

      Tii

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://34476]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-28 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found