Re: problem with Header("Location: home.php");
| From: | Chris Shiflett | Date: | Fri, 10 Sep 2004 20:47:06 +0000 |
| Subject: | Re: problem with Header("Location: home.php"); | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196358@lists.php.net to get a copy of this message | ||
--- CBharadwaj <bharadwaj@ontrackindia.com> 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/