Hi Ryan,
  Thanks for the examples.  Okay, I deleted the other stuff and just put
this code and I get this from
my interpreter?  Is this a setting problem?

Thanks,
Peter

<?php
header ("WWW-authenticate: Basic realm=\"Private\"");
header ("HTTP/1.0 401 Unauthorized");
echo "Unauthorized";
exit;
?>
*********************************************************
/* error message from the web server */
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator, [EMAIL PROTECTED] and inform them of
the time the error occurred, and anything you might have done that may have
caused the error.

More information about this error may be available in the server error log.

/* snipet from apache/logs/error.log */

[Mon Feb 04 22:36:30 2002] [error] [client 127.0.0.1] malformed header from
script. Bad header=HTTP/1.0 401 Unauthorized: /apache/php/php.exe




> Hello Peter. Good Day.
>
> Omitting <html></html> does not solve the problem. I've experience this
> problem also before. I found out that the once causing the problem is when
> any data that has been sent to the client. I have listed some example
below.
>
> Examples: All of these will cause a warning when header is called.
>
> 1. Since the tag <html> will be interpreted by the client browser first
> before the <?php ... ?> tags, data has been sent to the client, telling
the
> client that an html file is being rendered. So when the browser interprets
> the header function, a warning will be issued.
>
>     <html>
>     <?php
>             header( some parameters );
>             exit;
>      ?>
>
> 2. This will also cause an error. Remember that a call to an echo or print
> function will send data (the parameters of the function) to the client. So
> when the header is interpreted, a warning will be issued.
>
> <?php
>     echo "Some text";
>     header( some params );
>     exit;
> ?>
>
> Hope this is clear to you now. When a data has been sent already to the
> client, a call to a header will fail. The best thing you must do is to put
> the logic/check part on the first line of the file (See below). In the
> example below, I check first is the a user is valid by calling the the
> function verify_user( params... ) before any other html tags be rendered.
So
> when the user is not valid it will redirect an error page, if it is valid,
> the Welcome to page will be printed.
>
> <?php
>  session_start();
>  include 'include/config.inc';
>  include 'include/pgsql.inc';
>
>  if (!verify_user($username, $Password, $c_id))
>  {
>   session_register("isValid");
>   $isValid=false;
>   $title = "Web-based Training System Login";
>   $msg = "Access Denied!!!";
>   $link = "../../index.php?id=".$c_id;
>   header("Location:
>
notify2.php?title=".urlencode($title)."&msg=".urlencode($msg)."&link=".urlen
> code($link));
>   exit;
>  }
> ?>
> <html>
> <body>
>         Welcome to the page.
> </body>
> </html>
>
> Hope this help you more.
>
> Until then...
>
> Ryan F. Bayhonan
>
> ----- Original Message -----
> From: "Peter" <[EMAIL PROTECTED]>
> To: "Ryan F. Bayhonan" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Tuesday, February 05, 2002 2:14 PM
> Subject: Re: [PHP] Problem...header already sent by
>
>
> > Hi Ryan,
> >   I tried and took the <html></html> tags out and I still get the same
> > messaage.  Why?
> >
> > Thanks,
> > Peter
> >
> >
> > > Hello Peter.
> > >
> > > I discribe my reply below:
> > >
> > > > **************************
> > > > Warning: Cannot add header information - headers already sent by
> (output
> > > > started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in
> > > > C:\apache\htdocs\proj\sports\phps\verify.php on line 26
> > > > ***************************
> > >
> > > This warning message appear when the server already send data to the
> > client.
> > >
> > > > 1. <html>
> > > > 2. <?php
> > > >     ....
> > > >
> > > >
> > > >  23.   if (!$auth) {
> > > >  24.      header("www-Authenticate: Basic realm='Private'");
> > > >  25.      header("HTTP/1.0 401 Unauthrized");
> > > > ...
> > > > ?>
> > > > </html>
> > >
> > > In the above code, the <html></html> tag has been sent to the client
> > browser
> > > already, thus when calling header function it would cause a warning
> > telling
> > > you that data has been rendered already.
> > >
> > > Hope this help.
> > >
> > > Ryan
> > >
> > >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
>
>

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

Reply via email to