adly3000
Feb 5 2006, 10:53 PM
i really hate the header function it always get an error saying ( cannot ------- headers already sent by-----) and here's my error: Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/adly3000/public_html/Mail/index.php:5) in /home/adly3000/public_html/Mail/index.php on line 81 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/adly3000/public_html/Mail/index.php:5) in /home/adly3000/public_html/Mail/index.php on line 81 Warning: Cannot modify header information - headers already sent by (output started at /home/adly3000/public_html/Mail/index.php:5) in /home/adly3000/public_html/Mail/index.php on line 90 i don't know why it can not :send session cookie , send session cache limiter, or modify header information. and what do it mean ( headers already sent [output started] ) what is output started refers to?!!!! i have not an echo?!!!!
Reply
xJedix
Feb 5 2006, 11:37 PM
It would be useful to actually see the code to figure out specifically what is wrong..... But I have also had this issue..... For some reason php doesn't like spaces in the header. So try to remove all line spaces before the main part of the code/site, or the start of the <?php When I had this issue, I had something like this CODE <?php if ($username == NULL) {
$username = $usercook;
$password = $passcook;
} setcookie("usercook","$username",time()+5000,"/");
setcookie("passcook","$password",time()+5000,"/");
?>
<?php rest of code
When I was doing this type of stuff, that space in between the php codes messed it all up and gave me those errors. So just try removing the space so it looks like this CODE <?php if ($username == NULL) {
$username = $usercook;
$password = $passcook;
} setcookie("usercook","$username",time()+5000,"/");
setcookie("passcook","$password",time()+5000,"/");
?> <?php rest of code This could be the issue your having or something else.... From what you gave me, that's the only thing I can think of. Hope it helps
Reply
Yarrgh
Feb 6 2006, 02:26 AM
It would help a lot to have the code you use (header part) posted. QUOTE <?php if ($username == NULL) {
$username = $usercook;
$password = $passcook;
} setcookie("usercook","$username",time()+5000,"/");
setcookie("passcook","$password",time()+5000,"/");
?> <?php rest of code Why not just put the code in one <?php ... ?> ?
Reply
kvkv
Feb 6 2006, 02:36 AM
The "headers already sent [output started]" refers to any html content which has been written to the browser. When browser requests a page, the http server sends http headers before html contents. It means that if you are using php to send any headers, it must be done before writing any html output. Html output need not be just echo statement, but can be spaces or newline before the php tag (<?) because anything outside php tags is considered to be html. It is not that php (or any serverside scripting language for that matter -- like jsp or cgi-perl or asp) doesn't like spaces or newline, but it is the correct way it is supposed to behave. Make sure that you don't output anything to the browser before header function and no spaces/newline outside php tags and your problem will be solved.
Reply
Yarrgh
Feb 6 2006, 02:52 AM
The easiest thing to do is to seperate HTML from PHP. Make templates or something then use PHP to use that when everything that needs to be done is done. That way you don't have to worry about headers always giving you an error. And be sure you are not sending anything to the user in PHP before you start sending the headers. Or it will give you an error everytime. Also, after you send the headers you cannot resend them later on. If I am wrong about this let me know.
Reply
silentwind
Feb 6 2006, 05:35 AM
simple javascript function should fix that problem : CODE ?> <script language="javascript"> top.location.replace("http://www.path.you.want.to.redirect//"); </script> <?php
And about your error. It's because you have allready echo an output that is produced by your error. error = output some html code.
Reply
adly3000
Feb 6 2006, 07:04 AM
thanks all for replying; here's the lines 1-9: it says the problem is at line 5: CODE <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> .labelstyle {FONT-SIZE: 13PX; FONT-FAMILY: tahoma, Arial, Helvetica, sans-serif} .inputstyle {BACKGROUND: #ffffff; COLOR:#006699; FONT-FAMILY:tahoma, Arial, Helvetica, sans-serif; FONT-SIZE:13; BORDER-RIGHT: #006699 1px solid; BORDER-LEFT: #006699 1px solid; BORDER-TOP: #006699 1px solid; BORDER-BOTTOM: #006699 1px solid} </style> <script language="JavaScript"> as you can see its the css, which i can't remove!!!! and here's what i hope to do: 1- if the form did not submit echo form; 2- if the form submitted then: i- register the login data in session variables for later use. ii- header("Location: page.php"); final question: $hi = "welcome"; is that an output or i can assign any variables before the header?
Reply
Spectre
Feb 6 2006, 11:43 AM
If there is a posibility that PHP is going to send headers based on the outcome of something yet to be processed, you need to do all processing before any output is sent - ie. above the '<html>'. The second any output is sent, the headers are sent with it, and they can never be recalled and modified. Remember that PHP only deals with what's between the <?php ?> (or <? ?> depending on the configuration) tags, and everything else is ignored and instantly sent as output. CODE <?php // Any processing code needs to go here. ?><html> <head> <title>Untitled Document</title> I think this is about the 8,455,794th thread relating to exactly the same problem started on Trap17.
Reply
Amezis
Feb 6 2006, 12:39 PM
As everyone else have told you, the header function must be BEFORE the <html> tag. You can also have other PHP code before, but no HTML code.
Reply
antony2kx
Feb 13 2006, 09:55 PM
you know that you can jump in and out of php just write the html headers or the wml headers without stsrting with <?php and between the header and the footer you can just write you php script or code thet you want to use
Reply
Recent Queries:--
phpnuke warning: cannot modify header information - headers already sent by (output started at header.php - 10.48 hr back. (1)
-
php headers problem - 12.87 hr back. (1)
-
spaces in php mail from: header - 29.26 hr back. (1)
-
php "headers ignored" - 32.04 hr back. (1)
-
header php problems - 48.89 hr back. (1)
-
php header not working - 35.30 hr back. (2)
-
php resending headers on submit - 53.30 hr back. (1)
-
php headers not working javascript - 54.25 hr back. (2)
-
php header problems - 56.06 hr back. (1)
-
header problems in php - 56.36 hr back. (1)
-
php header problem - 60.84 hr back. (2)
-
header location problem internal link - 61.35 hr back. (1)
-
replace php header with javascript - 65.66 hr back. (1)
-
php, header(location:) not working - 66.82 hr back. (1)
Similar Topics
Keywords : php header header- [php] Header Function
- (2)
- Header Redirect Errors
- (5)
Hi, I am using the header function to redirect after the processing of the form. I have to specify
a internal link using '#link'. This works in Firefox and opera. But in Internet Explorer
internal linking when done from a redirect is not working for somewhat reasons. e.g.
header("Location: http://www.example.com/index.php#link"); this works in Firefox and Opera but
not in Internet Explorer . IE just accepts 'http://www.example.com/index.php' instead of
http://www.example.com/index.php#link Please help me if you know anything about this. Well ther...
Email Header Inject Test
- (0)
So I'm trying to write a script to check if someone is trying to do a header inject using my web
based email form. The problem is that, regardless of the content, it is being tagged as hijacked.
The following is the relevant part of my code: CODE $ip=$_POST['ip'];
$httpref=$_POST['httpref'];
$httpagent=$_POST['httpagent'];
$visitor=$_POST['visitor'];
$visitormail=$_POST['visitormail']; $s...
php header() function help needed
- automatic re-direct (4)
hey ppl, u seem to have real gud knowledge about php, i just wanted a little help...i designed this
website, but i want that if i click on certain page, it should open for some few seconds and then
browser should automatically redirect me to some other page....i tried this with header() function
but i couldnt do the wait n redirect part, ... so somebody plz help.... -thanx in advance!...
Need Help With The Header() Function
- I am redirecting from my old site (2)
Over a month ago, I bought a domain name for my site, but my site is still not indexed. I did
everything needed to get indexed, but I forgot one thing: The old site had exactly the same content
as the new one. So I had duplicate content. Therefore, I want my old site to redirect the user to
the new site with this script: CODE <?php header("Location:
http://www.global-rs.com" . $_SERVER['REQUEST_URI']); exit; ?>
global-rs.com is my new URL. However, on my old site, which I will be placing this code on, there
i...
Spacer Below Header :s
- (3)
Below my header, which includes the logo and a horizontal menu bar, there is an empty space of the
size of a linebreak. I'm completely new to PHP... My header is an include tag , and where the
top.htm site should end, there is a linebreak that I can't remove... Is there a way to remove
it? Also, it happens in my vertical menu too, and below the footer, but it doesn't really
affect the design....
Question On Header() Function
- (3)
Hello I have a question regarding the header(location:http:// etc) function. I have a php document
that looks similar to the followiing //now some code specific to this page only if blah blah {
do some stuff } else { header("location : http://some_page.php"); } include ("./bottom.php");
//this file contains loads of html and is resident on all pages in the site IT HAS TO BE HERE -----
my question is this, how can i redirect to a new page using the header() function in the middle of
a file like this ie when i have already passed a load of html and other stuf...
header()
- redirection (1)
CODE <?php if($_REQUEST['name']==NULL) {
header("Location:?name=Guest"); } else { ?> <html> <head>
<title>Welcome</title> </head> <body bgcolor=black> <?php
echo "<font color=gray><b>Hello, "; echo
$_REQUEST['name']."</b><p>"; ?><pre>
<?php for($i=0;$i<10;$i++) {
for($j=0;$j<10;$j++...
Looking for php, header, problem, header, problem
|
|
Searching Video's for php, header, problem, header, problem
|
advertisement
|
|