James Holden writes: 

> It's basically saying that you are outputing stuff to the browser before you
> are setting the cookies which is a no go.  All header requests (header() &
> setcookie()) must be run before any text is outputted. 
> 
sorry i'm new be in this...
could you show me where is in my script bellow
thanks!!! 

> Thus, the most common error is that after or before your php tags <? ?> is
> empty space, which to PHP is considered outputted text and you wont be able
> to set any headers. 
> 
> Other than that you might be setting cookies after you have echo'd templates
> or some such. 
> 
> 
> - James
> --------------------------
> W: www.londontown.com
> @: [EMAIL PROTECTED]
> -------------------------- 
> 
> -----Original Message-----
> From: Anton Heryanto [mailto:[EMAIL PROTECTED]]
> Sent: 30 May 2002 11:44
> To: [EMAIL PROTECTED]
> Subject: [PHP] user auth.. with mysql and cookies.. help 
> 
> 
> sorry, bother all of you with my same question
> i was learn to make user auth with mysql and using cookies, i have trouble
> with this error message; 
> 
> Warning: Cannot add header information - headers already sent by (output
> started at ../functions.inc:54) in ../functions.inc on line 49 
> 
> Warning: Cannot add header information - headers already sent by (output
> started at ../functions.inc:54) in ../functions.inc on line 50 
> 
> Warning: Cannot add header information - headers already sent by (output
> started at ../functions.inc:54) in ../functions.inc on line 51 
> 
> Warning: Cannot add header information - headers already sent by (output
> started at ../functions.inc:54) in ../login.php on line 12 
> 
> in this case i use 4 file ..
> 1)index.html -- sending data (methode post to login.php);
> 2)login.php
> 3)function.inc -- all the function i use
> 4)common.inc -- global variable; 
> 
> 2...login.php.................
> <?php
> require 'functions.inc';
> deleteCookies();
> if (authenticateUser($form_username, $form_password))
> {
>        setcookie("cookie_passwd", $form_password);
>        setcookie("cookie_user", $form_username);
>        header("Location:http://$http_host/$docroot/report.php";);
>        exit();
> }
> else{
> header("Location:http://$http_host/$docroot/error1.htm";);
> exit();
> } 
> 
> 3.function.inc
> <?
> require 'common.inc'; 
> 
> function DisplayErrMsg($message)
> {
> printf ("<blockquote><blockquote><blockquote><h3><fontcolor=\"#cc0000\">
> %s</font></h3></blockquote></blockquote></blockqoute>\n",$message);
> } 
> 
> 
> function authenticateUser($user, $password)
> { 
> 
>        global  $host, $httphost, $user_db, $password_db, $db, $docroot; 
> 
>        if (! ($link = mysql_pconnect($host, $user_db, $password_db)))
>                { 
> 
>                DisplayErrMsg(sprintf("internal Error %d: %s \n",
> mysql_errno(), mysql_error() ));
>                DisplayErrMsg(sprintf("internal Error %s %s %s %d: %s \n",
> $host, $user, $password, mysql_errno(), mysql_error() )); 
> 
>                return 0; 
> 
>        } 
> 
>        if (! ($result = mysql_db_query("$db","select * from user_login where
> userid = '$user'")))
>                {
>                DisplayErrMsg(sprintf("internal Error %d: %s \n",
> mysql_errno(), mysql_error() ));
>                return 0 ; 
> 
>                } 
> 
> 
>        if (($row = mysql_fetch_array($result)) &&
> ($password==$row["password"] && $password != "")) 
> 
>                return 1; 
> 
>        else
>                return 0; 
> 
> } 
> 
> function deleteCookies()
> {
>        for ($i=0; $i<$total_items; $i++)
>                {
>                setcookie("items_tray[$i]","");
>                setcookie("quantity[$i]","");
>                }
> setcookie("items_tray","");
> setcookie("total_items","");
> setcookie("quantity","");
> }
> ?> 
> 
> and 4. common.inc
> <?
> $host = "localhost";
> $user_db =  "root";
> $password_db = "";
> $db = "master_report";
> $http_host = "reymond.unri.ac.id/";
> $docroot = "security";
> ?>
> ~ 
> 
> could you tell me what and where  is the mistake ...
> thank for all of you all kindness 
> 
> regards 
> 
> anton
>  ------Linux is Power------- 
> 
> --
> 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 
> 
 


 ------Linux is Power------- 

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

Reply via email to