473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help: Redirct error: headers already written

I'm getting an error:" http headers already written", when I redirect
back the page I came from.
I writing an on-line store app. The page 1 lists products, desc,
price in a table. Click on a product, it adds it to an XML shopping
bag and , thru a link, jumps to page2 that prints everyhing in the bag
so far. At the bottom of page2 is a TYPE SUBMIT button that takes you
back to page 1 for more shopping. The form for the button uses

Response.Write "<FORM METHOD=""POST"" ACTION="""
Response.Write Request.ServerVariables("SCRIPT_NAME") & """>"
....
Response.Write "<INPUT TYPE=SUBMIT NAME=""DO"" VALUE=""Shop
for more"">&nbsp;"

to post the button data back to itself. The following checks if the
button was pushed and redirects to page1 if it was:

If Request.ServerVariables("CONTENT_LENGTH")>0 Then
Select Case Trim(Request.Form("DO"))
Case "Shop for more"
Response.Redirect "page1.asp"
Response.End
....
End Select
End If

Problem is, when I click the bi\utton, the error about headers already
written comes up.
I think it's because HTML commands have been written before the
redirct, but I don't know how to work around it.
Any help?
Jul 19 '05 #1
2 1375
http://www.aspfaq.com/2011
http://www.aspfaq.com/2217

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


<sd******@hotmail.com> wrote in message
news:o0********************************@4ax.com...
I'm getting an error:" http headers already written", when I redirect
back the page I came from.
I writing an on-line store app. The page 1 lists products, desc,
price in a table. Click on a product, it adds it to an XML shopping
bag and , thru a link, jumps to page2 that prints everyhing in the bag
so far. At the bottom of page2 is a TYPE SUBMIT button that takes you
back to page 1 for more shopping. The form for the button uses

Response.Write "<FORM METHOD=""POST"" ACTION="""
Response.Write Request.ServerVariables("SCRIPT_NAME") & """>"
....
Response.Write "<INPUT TYPE=SUBMIT NAME=""DO"" VALUE=""Shop
for more"">&nbsp;"

to post the button data back to itself. The following checks if the
button was pushed and redirects to page1 if it was:

If Request.ServerVariables("CONTENT_LENGTH")>0 Then
Select Case Trim(Request.Form("DO"))
Case "Shop for more"
Response.Redirect "page1.asp"
Response.End
....
End Select
End If

Problem is, when I click the bi\utton, the error about headers already
written comes up.
I think it's because HTML commands have been written before the
redirct, but I don't know how to work around it.
Any help?

Jul 19 '05 #2
Thanks! That Buffer = true did the trick!
On Sat, 21 Feb 2004 11:49:48 -0500, "Aaron Bertrand [MVP]"
<aa***@TRASHaspfaq.com> wrote:
http://www.aspfaq.com/2011
http://www.aspfaq.com/2217


Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
5
by: Philip Ronan | last post by:
OK, here's my 2p worth: === Q. Why am I getting the error message 'Headers already sent'? A. PHP produces this error message when you try to set a header for a web page after you have already...
3
by: dont bother | last post by:
Hi, I have written this small piece of code. I am a brand new player of Python. I had asked some people for help, unfortunately not many helped. Here is the code I have: import email import...
5
by: Bernard | last post by:
Hi, I have a problem with a CGI script (Perl) on a Win2000 server. The script is for sending E-cards and was written by Jason Maloney:...
22
by: Platero | last post by:
Hi, I've a stupid question but... The code is the following: if(($role!='tutor')&&(array_key_exists('tutor_id',$_GET))) { $possible_ids = array(2,6,7,8,9,10); $t_id = $_GET;
2
by: Comcast | last post by:
I am using a form that uses PHP to create an e-mail and send it off. When the script runs, I get an error page, although the e-mail is sent off. The error I am getting is: Warning:...
4
by: craigtomo | last post by:
I am getting the following error when i try to log on to my data base Warning: session_register() : Cannot send session cookie - headers already sent by (output started at...
15
by: Lawrence Krubner | last post by:
Does anything about this script look expensive, in terms of resources or execution time? This script dies after processing about 20 or 25 numbers, yet it leaves no errors in the error logs. This is...
2
mideastgirl
by: mideastgirl | last post by:
Warning: session_start() : Cannot send session cookie - headers already sent by (output started at /home/content/m/i/d/mideasthonors/html/adminloginprocess.php:1) in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.