RE: [PHP] Header information ...
| From: | Daniel Kushner | Date: | Fri, 10 Jan 2003 16:20:56 +0000 |
| Subject: | RE: [PHP] Header information ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-131134@lists.php.net to get a copy of this message | ||
Hi Anders,
You can't send a header to the browser once output has been sent. The
header() function should be before any other output on your script. Further
more, because the script isn't terminated after the header() function, and
you usually do not want to continue running it, an exit() should directly
follow.
e.g.:
Header("Location: main.php");
exit();
Regards,
Daniel Kushner
_________________________________________
Need hosting? http://thehostingcompany.us
> -----Original Message-----
> From: Anders Mellstrom [mailto:anders@glimville.se]
> Sent: Friday, January 10, 2003 11:18 AM
> To: php-general@lists.php.net
> Subject: [PHP] Header information ...
>
>
> Hello. I can't get this code to work. The error message I get is
> that the header could be added, cause it has allready been sent.
> What shalll I do to get it to work?
>
> //Anders
>
> <html>
> <head>
> <title></title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
>
> <script language="JavaScript">
> if ((navigator.appName == "Netscape") &&
> (parseInt(navigator.appVersion) > 5))
> {
> window.alert("Upgrade version of NS.");
> }
> else
> {
> document.write("<?php $i = 1 ?>");
> }
> </script>
>
> <link rel='stylesheet' href='stil.css' type='text/css'>
> </head>
> <body>
>
> <br>
>
> <?php
> if ($i == 1)
> {
>
> Header("location:main.php");
> }
> else
> {
> print("Byt webbläsare!");
> }
> ?>
> </body>
> </html>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php