[Webinar] Streamline your web hosting managementRegister Today


CGI Header Problem

Posted on 2003-03-31
Medium Priority
Last Modified: 2012-05-04
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.

Question by:acdesigns
LVL 48

Accepted Solution

Tintin earned 75 total points
ID: 8242261
You can only output one header.  It has to either be a Content-Type or a Location header, not both.
LVL 20

Expert Comment

ID: 8242749
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.

Expert Comment

ID: 8246336
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()


Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question