Re: [PHP] problem with Header("Location: home.php");

2004-09-10 Thread Chris Shiflett
--- CBharadwaj <[EMAIL PROTECTED]> wrote:
> In conection.php I have written.
> SESSION_ START();
> 
> on successful login I am registering a session variable.
> SESSION_REGISTER("userId");


Do this instead:

session_start();
$_SESSION['userid'] = 'myuser';

>  Header("Location: home.php");

Use an absolute URL:

header('Location: http://example.org/home.php');

> Warning: Cannot modify header information - headers already sent by 
> (output started at E:\PHPMySql scripts\bugtrack\connection.php:3)
>  in E:\PHPMySql scripts\bugtrack\index.php on line 117

This call to header() on line 117 of index.php generates an error, because
line 3 of connection.php generated output. Calls to header() must come
prior to output. You can either rearrange your code or use output
buffering:

http://www.php.net/ob_start

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] problem with Header("Location: home.php");

2004-09-09 Thread Andre Dubuc
On Thursday 12 August 2004 07:48 pm, CBharadwaj wrote:
> Hello,
>
> In conection.php I have written.
> SESSION_ START();
   ^

Get rid of extra space and it should work
Hth,
Andre


> on successful login I am registering a session variable.
> SESSION_REGISTER("userId");
>
> on login failure  I am redirecting to home page.
>  Header("Location: home.php");
>
>
> the following error occuring in above line.
> Warning: Cannot modify header information - headers already sent by
> (output started at E:\PHPMySql scripts\bugtrack\connection.php:3)
>  in E:\PHPMySql scripts\bugtrack\index.php on line 117
>
> the connection file I have included in every page.
> why this error is occuring?
>
>
> Bharadwaj

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] problem with Header("Location: home.php");

2004-09-09 Thread Paul Waring
> the following error occuring in above line.
> Warning: Cannot modify header information - headers already sent by
> (output started at E:\PHPMySql scripts\bugtrack\connection.php:3)
>  in E:\PHPMySql scripts\bugtrack\index.php on line 117

Have you got any space before you output anything to the browser? I've
found that often I've saved a file with a newline at the end by
accident - meaning that PHP thinks I'm ready to start sending output
and therefore any functions that modify the headers won't work because
they've already been sent.

Check connection.php around line 3 to see if there is anything sending
output before you call session_* or Header().

BTW, you shouldn't use relative URIs in Location: headers, try using:

header('Location: http://www.mydomain.com/path/to/home.php');

instead (this won't fix anything, but it's the correct way to do it
according to the HTTP/1.1 standard).

Hope this helps,

Paul

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] problem with Header("Location: home.php");

2004-09-09 Thread CBharadwaj
Hello,

In conection.php I have written.
SESSION_ START();

on successful login I am registering a session variable.
SESSION_REGISTER("userId"); 

on login failure  I am redirecting to home page.
 Header("Location: home.php");


the following error occuring in above line.
Warning: Cannot modify header information - headers already sent by 
(output started at E:\PHPMySql scripts\bugtrack\connection.php:3)
 in E:\PHPMySql scripts\bugtrack\index.php on line 117

the connection file I have included in every page.
why this error is occuring?


Bharadwaj

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php