Link to home
Start Free TrialLog in
Avatar of acdesigns
acdesigns

asked on

CGI Header Problem

I have a redirect on one of my scripts which is supposed to take the browser to another page once the script is complete.  

$successurl = 'http://www.domain.com/';
print "Location: $successurl\n\n";

The problem I'm having is that it's simply printing that on screen not redirecting.  I understand that somewhere in the script it sends the header as print "Content-type: text/html\n\n";  but how do I cancel that when it gets to this section.  I don't want it to print to screen but instead redirect to page.  Is there a different header I could put on top of the above two lines?

Thanks for your help.  This has been driving me nuts for two days.

ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Once that double newline is sent, you've ended the HTTP header and can't add any new header lines. You need to arrange your script so you are not attempting to send multiple, conflicting headers.
Avatar of BlackFire
BlackFire

as said above, as soon as you use print, the data you printed goes directly to the end user. So once you print it, you cant go back and stop it.  Try doing text search for "content-type" if you dont know where it is.  Another method i use, is put all your headers in a variable, and dont print them until you start printing your content.  Make it a sub like:

&AddHeader()  &DelHeader()  &PrintHeader()