plik index.php
<?php
?>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK href="style.css" rel=stylesheet type=text/css>
</head>
<body bgcolor="#E0E1D9"><center>
<?php
$mysql_host = "localhost";
$mysql_login = "root";
$mysql_pass = "";
$mysql_baza = "baza2";
$mysql_tabela = "users";
//********************************************************************************
*****************************************************
//********************************** Wylogowanie i zalogowanie z ustaleniem sesji
******************************************
//********************************************************************************
*****************************************************
$users_login = $_POST['login'];
$users_pass = $_POST['haslo'];
if($_GET['login']=="koniec") { //wylogowanie
sesion_destroy();
}
else if($users_login<>"" and $users_pass<>"") {
//$users_pass = md5($users_pass);
if($baza = mysql_connect($mysql_host, $mysql_login, $mysql_haslo)) { $wynik = mysql_query("SELECT * FROM $mysql_tabela WHERE users_login='$users_login' and users_pass='$users_pass'") or
die(mysql_error()); $_SESSION['zalogowany']="tak";
$_SESSION['login']=$dane['login'];
}
} else echo "Nie można się połączyć z bazą"; }
}
//********************************************************************************
*****************************************************
//********************************** Panel formularza do zalogowania i wylogowania
***************************************
//********************************************************************************
*****************************************************
if($_SESSION['zalogowany']=="tak") {
echo "<p>Witaj <b>".$_SESSION['login']."</b></p>"; echo "<br><a href=\"index.php?login=koniec\">Wyloguj się</a>"; }
else{
<form action="index.php" method="post">
<table>
<tr>
<td>Login:</td>
<td><input type="text" name="login" /></td>
</tr>
<tr>
<td>Haslo:</td>
<td><input type="password" name="haslo" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="zaloguj" />
</td>
</tr>
</table>
KONIEC;
}
if($_SESSION['zalogowany']=="tak") {
echo "<p>Tekst widzi osoba zalogowana</p>"; }
?>
</body>
</html>
logowanie dziala zapomialem ze haslo mialem szyfrowane...
ale nadal mam ten blad sesji
Warning: session_start() [
function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Program Files\WebServ\httpd-users\test2\index.php:1) in
C:\Program Files\WebServ\httpd-users\test2\index.php on line
3 Warning: session_start() [
function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\WebServ\httpd-users\test2\index.php:1) in
C:\Program Files\WebServ\httpd-users\test2\index.php on line
3