Грешка

nanov_91

Registered
Какви са тези грешки?
Код:
Warning: Cannot modify header information - headers already sent by (output started at /home/www/mezdra.awardspace.com/new.php:4) in /home/www/mezdra.awardspace.com/login.php on line 43

Warning: Cannot modify header information - headers already sent by (output started at /home/www/mezdra.awardspace.com/new.php:4) in /home/www/mezdra.awardspace.com/login.php on line 44

Ето какво има на тези редове
43 ред
Код:
setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
44
Код:
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
 
значи преди <?php не трябва да има нищо, нито html код, нито празни поленца. общо взето <?php трябва да започва в самото начало
 
Еми то няма нищо! Имам една страница нею.пхп и в нея има таблица в която инклудвам логин.пхп.
 
new.php
Код:
<html>
<head><title>Мисли глобално действай локално!</title></head>
<body><center><table border="1" width="80%"><tr><td width="110">left</td><td>center</td><td width="110">right</td></tr>
<tr><td width="110"><?php
include ("login.php");
?></td><td>center</td><td width="110">right</td></tr>
<tr><td width="110">left</td><td>center</td><td width="110">right</td></tr>
<tr><td width="110">left</td><td>center</td><td width="110">right</td></tr></table></center></body>
</html>

login.php
Код:
<? 
oB_start(); 
// allows you to use cookies. 
include("nast.php"); 
if (!$logged[username]) 
{ 
if (!$_POST[login]) 
{ 
echo(" 
<center><form method=\"POST\"> 
<table> 
<tr> 
<td align=\"right\"> 
Потребител: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"> 
</td> 
</tr> 
<tr> 
<td align=\"right\"> 
Парола: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\"> 
</td></tr><tr> 
<td align=\"center\"> 
<input type=\"submit\" name=\"login\" value=\"Влез\"> 
</td></tr><tr> 
<td align=\"center\"> 
<a href=\"register.php\">Регистрирай се</a> 
</td></tr></table></form></center>"); 
} 
if ($_POST[login]) { 
// the form has been submitted. We continue... 
$username=$_POST['username']; 
$password = md5($_POST[password]); 
// the above lines set variables with the submitted information. 
$info = mysql_query("SELECT * FROM register WHERE username = '$username'") or die(mysql_error()); 
$data = mysql_fetch_array($info); 
if($data[password] != $password) { 
// the password was not the user's password! 
echo "Грешен потребител или парола!"; 
}else{ 
// the password was right! 
$query = mysql_query("SELECT * FROM register WHERE username = '$username'") or die(mysql_error()); 
$user = mysql_fetch_array($query); 
// gets the user's information 
 setcookie("id", $user[id],time()+(60*60*24*5), "/", ""); 
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
// the above lines set 2 cookies. 1 with the user's id and another with his/her password. 
echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=\"/>Вие успешно влязохте в акаунта си."); 
// modify the above line...add in your site url instead of yoursite.com 
} 
} 
} 
else 
{ 
// we now display the user controls. 
echo ("<center>Добре дошли <b>$logged[username]</b><br /></center> 
<a href=\"editprofile.php\">Промени профила си</a><br /> 
<a href=\"members.php\">Виж всички регистрирани потребители</a><br /> 
<a href=\"search.php\">Търси за потребители</a><br />
<a href=\"logout.php\">Излез от акаунта си</a>"); 
} 

echo'<br><br>
Статистика:<br>';

$last = mysql_query("SELECT id, username FROM register ORDER BY id DESC LIMIT 1"); 
while($q=mysql_fetch_assoc($last)){ 
echo "<b>Последно регистриран:</b> 
<a href='members.php?user=". $q['username'] ."'>".$q['username']."</a><br />";} 


$register = mysql_query("SELECT count(id) as total FROM register"); 
while($c=mysql_fetch_array($register)){ 
echo "<b>Брой потребители:</b>" .$c['total']. ""; } 

echo '<br>'; 


$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
$cutoff = 15; //online cut of time
$exists = 0;
$users = 0;
$user = "";

$fp = fopen ("online.txt","r+"); //if the file exists open it

while (!feof($fp))
{
$user[] = chop(fgets($fp,65536));
}
fseek($fp,0,SEEK_SET);


foreach ($user as $line)
{
list($oldip,$oldtime) = explode('|',$line);
if ($oldip == $ip) {$oldtime = $time;$exists = 1;} //check to see if the user is already in the text file
if ($time < $oldtime + ($cutoff * 60)) //see if the last time the user visited is past the cut off time
{
fputs($fp,"$oldip|$oldtime\n"); //write the old data to the text file
$users = $users + 1; // add one to the user count
}
}


if ($exists == 0) //if the user isn't in the text file already:
{
fputs($fp,"$ip|$time\n"); //write the new data to the text file
$users = $users + 1; //add one to the user count
}


fclose ($fp); //close the text file
print "<b>Online:</b> $users"; //display the number of users online

?>
 
new.php

Код:
<? 
oB_start(); 
// allows you to use cookies. 
include("nast.php");
?>
<html> 
<head><title>Мисли глобално действай локално!</title></head> 
<body><center><table border="1" width="80%"><tr><td width="110">left</td><td>center</td><td width="110">right</td></tr> 
<tr><td width="110"><?php 
include ("login.php"); 
?></td><td>center</td><td width="110">right</td></tr> 
<tr><td width="110">left</td><td>center</td><td width="110">right</td></tr> 
<tr><td width="110">left</td><td>center</td><td width="110">right</td></tr></table></center></body> 
</html>

login.php

Код:
<? 
if (!$logged[username]) 
{ 
if (!$_POST[login]) 
{ 
echo(" 
<center><form method=\"POST\"> 
<table> 
<tr> 
<td align=\"right\"> 
Потребител: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"> 
</td> 
</tr> 
<tr> 
<td align=\"right\"> 
Парола: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\"> 
</td></tr><tr> 
<td align=\"center\"> 
<input type=\"submit\" name=\"login\" value=\"Влез\"> 
</td></tr><tr> 
<td align=\"center\"> 
<a href=\"register.php\">Регистрирай се</a> 
</td></tr></table></form></center>"); 
} 
if ($_POST[login]) { 
// the form has been submitted. We continue... 
$username=$_POST['username']; 
$password = md5($_POST[password]); 
// the above lines set variables with the submitted information. 
$info = mysql_query("SELECT * FROM register WHERE username = '$username'") or die(mysql_error()); 
$data = mysql_fetch_array($info); 
if($data[password] != $password) { 
// the password was not the user's password! 
echo "Грешен потребител или парола!"; 
}else{ 
// the password was right! 
$query = mysql_query("SELECT * FROM register WHERE username = '$username'") or die(mysql_error()); 
$user = mysql_fetch_array($query); 
// gets the user's information 
 setcookie("id", $user[id],time()+(60*60*24*5), "/", ""); 
setcookie("pass", $user[password],time()+(60*60*24*5), "/", ""); 
// the above lines set 2 cookies. 1 with the user's id and another with his/her password. 
echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=\"/>Вие успешно влязохте в акаунта си."); 
// modify the above line...add in your site url instead of yoursite.com 
} 
} 
} 
else 
{ 
// we now display the user controls. 
echo ("<center>Добре дошли <b>$logged[username]</b><br /></center> 
<a href=\"editprofile.php\">Промени профила си</a><br /> 
<a href=\"members.php\">Виж всички регистрирани потребители</a><br /> 
<a href=\"search.php\">Търси за потребители</a><br /> 
<a href=\"logout.php\">Излез от акаунта си</a>"); 
} 

echo'<br><br> 
Статистика:<br>'; 

$last = mysql_query("SELECT id, username FROM register ORDER BY id DESC LIMIT 1"); 
while($q=mysql_fetch_assoc($last)){ 
echo "<b>Последно регистриран:</b> 
<a href='members.php?user=". $q['username'] ."'>".$q['username']."</a><br />";} 


$register = mysql_query("SELECT count(id) as total FROM register"); 
while($c=mysql_fetch_array($register)){ 
echo "<b>Брой потребители:</b>" .$c['total']. ""; } 

echo '<br>'; 


$ip = $_SERVER['REMOTE_ADDR']; 
$time = time(); 
$cutoff = 15; //online cut of time 
$exists = 0; 
$users = 0; 
$user = ""; 

$fp = fopen ("online.txt","r+"); //if the file exists open it 

while (!feof($fp)) 
{ 
$user[] = chop(fgets($fp,65536)); 
} 
fseek($fp,0,SEEK_SET); 


foreach ($user as $line) 
{ 
list($oldip,$oldtime) = explode('|',$line); 
if ($oldip == $ip) {$oldtime = $time;$exists = 1;} //check to see if the user is already in the text file 
if ($time < $oldtime + ($cutoff * 60)) //see if the last time the user visited is past the cut off time 
{ 
fputs($fp,"$oldip|$oldtime\n"); //write the old data to the text file 
$users = $users + 1; // add one to the user count 
} 
} 


if ($exists == 0) //if the user isn't in the text file already: 
{ 
fputs($fp,"$ip|$time\n"); //write the new data to the text file 
$users = $users + 1; //add one to the user count 
} 


fclose ($fp); //close the text file 
print "<b>Online:</b> $users"; //display the number of users online 

?>
 

Back
Горе