473,769 Members | 2,106 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Header help

Hiya, just need help with PHP headers.

I have an index php page which has the following code within a header
redirect:

<?php
if ( empty($_GET['month']) )
if (empty($_GET['year']) )
{
$month = date(n);
$year = date(Y);
header("Locatio n: index.php?month =$month&year=$y ear");
}
?>

On the same index.php page, I have a shoutbox (include file) which inputs
the content of the shoutbox form into a database. After the user fills out
the form, I want the index page to refresh again because if I leave it as it
is and a user inputs info into the form, if they press refresh, the form
resubmits thus recording two entries into the shoutbox, or however many
times refresh is pressed.

When I add a header redirect into the shoutbox include file, once the user
clicks on send, index.php throws a headers cannot be sent error message.

Can anyone help?

Cheers.

Jul 17 '05 #1
11 2316
DaRemedy wrote:
Hiya, just need help with PHP headers.

Multi-posting to at least three different news groups, it looks like you
need some help posting to usenet properly to...

If you want to post to more than 1 newsgroup, use the Newsgroups: field to
compose a comma-seperated list of target news groups. This procedure is
called "Cross-posting" and prevents individual threads on the same topic.
See the headers of this reply.
When I add a header redirect into the shoutbox include file, once the
user clicks on send, index.php throws a headers cannot be sent error
message.


To quote the manual page at http://www.php.net/header:

"Remember that header() must be called before any
actual output is sent, either by normal HTML
tags, blank lines in a file, or from PHP. It is a
very common error to read code with include(), or
require(), functions, or another file access function,
and have spaces or empty lines that are output before
header() is called. The same problem exists when using
a single PHP/HTML file."
JW

Jul 17 '05 #2
I do apologise for cross posting.

"Janwillem Borleffs" <jw@jwscripts.c om> wrote in message
news:41******** *************** @news.euronet.n l...
DaRemedy wrote:
Hiya, just need help with PHP headers.


Multi-posting to at least three different news groups, it looks like you
need some help posting to usenet properly to...

If you want to post to more than 1 newsgroup, use the Newsgroups: field to
compose a comma-seperated list of target news groups. This procedure is
called "Cross-posting" and prevents individual threads on the same topic.
See the headers of this reply.
When I add a header redirect into the shoutbox include file, once the
user clicks on send, index.php throws a headers cannot be sent error
message.


To quote the manual page at http://www.php.net/header:

"Remember that header() must be called before any
actual output is sent, either by normal HTML
tags, blank lines in a file, or from PHP. It is a
very common error to read code with include(), or
require(), functions, or another file access function,
and have spaces or empty lines that are output before
header() is called. The same problem exists when using
a single PHP/HTML file."
JW

Jul 17 '05 #3
Even if I add the headers before any html output and making sure that there
is no whitespace, the header still doesn't work, is it because the header o
the index.php page is already being called? how do I get around it?

Many thanks.

"DaRemedy" <de******@btint ernet.com.nospa m> wrote in message
news:cj******** **@titan.btinte rnet.com...
I do apologise for cross posting.

"Janwillem Borleffs" <jw@jwscripts.c om> wrote in message
news:41******** *************** @news.euronet.n l...
DaRemedy wrote:
Hiya, just need help with PHP headers.


Multi-posting to at least three different news groups, it looks like you
need some help posting to usenet properly to...

If you want to post to more than 1 newsgroup, use the Newsgroups: field to compose a comma-seperated list of target news groups. This procedure is
called "Cross-posting" and prevents individual threads on the same topic. See the headers of this reply.
When I add a header redirect into the shoutbox include file, once the
user clicks on send, index.php throws a headers cannot be sent error
message.


To quote the manual page at http://www.php.net/header:

"Remember that header() must be called before any
actual output is sent, either by normal HTML
tags, blank lines in a file, or from PHP. It is a
very common error to read code with include(), or
require(), functions, or another file access function,
and have spaces or empty lines that are output before
header() is called. The same problem exists when using
a single PHP/HTML file."
JW


Jul 17 '05 #4
DaRemedy wrote:
Even if I add the headers before any html output and making sure that there
is no whitespace, the header still doesn't work, is it because the header o
the index.php page is already being called? how do I get around it?


You have to be sure there aren't any whitespaces or html output on files that
are included too.

If you have more tha one header in the same file and they try to do simlare
things you will run into a conflict (think the first one is the one that will
be executed).
Jul 17 '05 #5
Cheers for that,

I managed to get it sorted using an 'if statement'. I made is so that if the
shoutbox form is sent then to go to back index.php otherwise go to
index.php?month =$month&year=$y ear. Telling the form to go back to index.php
would call the month and year variables anyway, using:
<?php
(if form is sent do this) {
header("Locatio n: index.php");
} else {
if ( empty($_GET['month']) )
if (empty($_GET['year']) )
{
$month = date(n);
$year = date(Y);
header("Locatio n: index.php?month =$month&year=$y ear");
}
?>

Cheers for the help guys, really do appreciate it.

"J.O. Aho" <us**@example.n et> wrote in message
news:2r******** *****@uni-berlin.de...
DaRemedy wrote:
Even if I add the headers before any html output and making sure that
there
is no whitespace, the header still doesn't work, is it because the header
o
the index.php page is already being called? how do I get around it?


You have to be sure there aren't any whitespaces or html output on files
that are included too.

If you have more tha one header in the same file and they try to do
simlare things you will run into a conflict (think the first one is the
one that will be executed).

Jul 17 '05 #6
.oO(Sippy)

One more thing:
header("Locati on: index.php?month =$month&year=$y ear");


The Location-header requires an absolute address, including the scheme
(http://) and hostname.

Micha
Jul 17 '05 #7
Thanks Michael,

Is it absolutely nessecary to use an absolute address? because the code i
posted in an earlier post seems to work fine without any problems.

What I would really need to do is to change the header redirect slightly to
redirect to the same page that the shoutbox was filled in from, e.g. the
shoutbox was filled in from, lets say, the about.php page, so I would want
the shoutbox to go back to that particular page after the form is submitted.
Would I need to use $_SERVER['PHP_SELF'];

Cheers.

Sippy.

"Michael Fesser" <ne*****@gmx.ne t> wrote in message
news:fa******** *************** *********@4ax.c om...
.oO(Sippy)

One more thing:
header("Locati on: index.php?month =$month&year=$y ear");


The Location-header requires an absolute address, including the scheme
(http://) and hostname.

Micha

Jul 17 '05 #8
.oO(DaRemedy)
Is it absolutely nessecary to use an absolute address? because the code i
posted in an earlier post seems to work fine without any problems.
It works in most browsers (doesn't necessarily mean it'll work in all),
but a full address is required by the HTTP specification (RFC 2616):

"The field value consists of a single absolute URI."

In the PHP manual there's a little example on how to add scheme and
hostname automatically to build an absolute address from a relative one
for an RFC-compliant Location-header.

http://www.php.net/header
What I would really need to do is to change the header redirect slightly to
redirect to the same page that the shoutbox was filled in from, e.g. the
shoutbox was filled in from, lets say, the about.php page, so I would want
the shoutbox to go back to that particular page after the form is submitted.
Would I need to use $_SERVER['PHP_SELF'];


Yep.

Micha
Jul 17 '05 #9
Cheers matey, I really do appreciate your help.

"Michael Fesser" <ne*****@gmx.ne t> wrote in message
news:1n******** *************** *********@4ax.c om...
.oO(DaRemedy)
Is it absolutely nessecary to use an absolute address? because the code i
posted in an earlier post seems to work fine without any problems.


It works in most browsers (doesn't necessarily mean it'll work in all),
but a full address is required by the HTTP specification (RFC 2616):

"The field value consists of a single absolute URI."

In the PHP manual there's a little example on how to add scheme and
hostname automatically to build an absolute address from a relative one
for an RFC-compliant Location-header.

http://www.php.net/header
What I would really need to do is to change the header redirect slightly toredirect to the same page that the shoutbox was filled in from, e.g. the
shoutbox was filled in from, lets say, the about.php page, so I would wantthe shoutbox to go back to that particular page after the form is submitted.Would I need to use $_SERVER['PHP_SELF'];


Yep.

Micha

Jul 17 '05 #10

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

Similar topics

2
3201
by: Thomas Kemmerich | last post by:
hi, i'm looking for a possibility to start a download. here is my current code: header("Content-Type: $_contenttype"); header("Content-Disposition: attachment; filename=\"$_filename\""); // flush();
18
13625
by: Frank Thorstens | last post by:
Hi, i try to give my script headers so the output text would be downloaded in the client's browser and not displayed. But it doesn't work at all in my IE 6 and Opera. <? header("Content-Type: application/octet-stream"); header("Content-Length: 5"); header("Content-Transfer-Encoding: binary");
0
1556
by: Luke Airig | last post by:
I am using the Saxon engine and I have an xml file that contains batches of records. Each batch starts with a header record and the associated detail records immediately follow each header. There can be multiple batches in a single file, each batch indicated by a new header. I need to create a tab-delimited output file that appends all of the header record fields in front of each associated detail record within the same batch. The...
2
6133
by: Karthik | last post by:
When I try to compile my VC++ program (am Using VS6.0). I get the following error in a header file ATLCONV.H. c:\program files\microsoft visual studio\vc98\atl\include\atlconv.h(52) : error C2065: '_ASSERTE' : undeclared identifier Error executing cl.exe. and it points to inline LPWSTR WINAPI AtlA2WHelper(LPWSTR lpw, LPCSTR lpa, int nChars,
4
7846
by: Matthew Harvey | last post by:
Hello, I am having a problem getting a custom soap header to work with PHP5. What I require is something like this: <SOAP-ENV:Header> <USER>myusername</USER> <PASSWORD>mypassword</PASSWORD> </SOAP-ENV:Header> What I get is : <SOAP-ENV:Header>
3
2335
by: Grim Reaper | last post by:
I know this is probably an easy question, but I could not find/figure it out. Basically, I am printing mailing labels with a "Sorting/Grouping" section that groups the label types together. Also, I am using a "Report Header" to show a count of how many total labels that are being printed. Now, my problem is that without the "Report Header", the spacing is perfect. But, when I add the Report Header, it gets shifted downwards and the...
2
4236
by: saleek | last post by:
I was wondering if there is a way I can add an extra header to a datagrid? I found this solution on the internet - but it seems quite old and didn't work for me. http://www.dotnet247.com/247reference/msgs/13/69744.aspx It recommends the following: Private Sub DataGrid1_PreRender(ByVal sender As Object, ByVal e As
3
1866
by: jszczepankiewicz | last post by:
Witam, mam nastepujacy problem: XSLT 2.0, Hi, i've got following problem with xslt 2: my xml doc looks something linke: <manual>
10
1565
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello misters, I have an DAtalist that generates an html table with a header. There are many rows, and I want that it appears scroll horizontal and vertical, and the header be fixed. Any help ? Thanks in advance. -- http://www.alhambra-eidos.es/web2005/index.html www.kiquenet.net
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.