Помогите плиз. Незнаю почему но куки не создаются. Вот ошибки
Warning: Cannot modify header information - headers already sent by (output started at Z:\home\localhost\www\project_site\templates\main_login.php:12) in Z:\home\localhost\www\project_site\templates\content_login.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at Z:\home\localhost\www\project_site\templates\main_login.php:12) in Z:\home\localhost\www\project_site\templates\content_login.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at Z:\home\localhost\www\project_site\templates\main_login.php:12) in Z:\home\localhost\www\project_site\templates\content_login.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at Z:\home\localhost\www\project_site\templates\main_login.php:12) in Z:\home\localhost\www\project_site\templates\content_login.php on line 7
Код:
<?
function login($username, $password)
{
if (isset($_POST['pass']) && isset($_POST['login']) && $_POST['login'] == $username && $_POST['pass'] == $password)
{
setcookie('username', $username, time() + 3600 * 24 * 7);
setcookie('password', $password, time() + 3600 * 24 * 7);
session_start();
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
}
}
function logout()
{
if (isset($_COOKIE['username']))
{
setcookie('username', '', time() - 1);
}
if (isset($_COOKIE['password']))
{
setcookie('password', '', time() - 1);
}
if (isset($_SESSION['username']))
{
session_start();
unset($_SESSION['username']);
}
if (isset($_SESSION['username']))
{
session_start();
unset($_SESSION['password']);
}
}
require_once('config/config_index.php');
$result = mysql_query('SELECT login, password FROM users WHERE id_user=1');
$user = mysql_fetch_array($result);
logout();
login($user[0], $user[1]);
?>
<table width="247" height="213" align="center" background="img/login.png">
<tr>
<td>
<blockquote><form method="post">
<h2>Вход</h2>
Логин: <input type="text" name="login" />
<br/>Пароль: <input type="password" name="pass" />
<br/><input type="submit" value="Войти" />
</form></blockquote>
</td>
</tr>
</table>