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