Próbuję stworzyć skrypt logowania oparty o sesję ale wywala mi takie błędy:
Kod
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Program Files (x86)\WebServ\httpd\strona\index.php:2) in C:\Program Files (x86)\WebServ\httpd\strona\index.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files (x86)\WebServ\httpd\strona\index.php:2) in C:\Program Files (x86)\WebServ\httpd\strona\index.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files (x86)\WebServ\httpd\strona\index.php:2) in C:\Program Files (x86)\WebServ\httpd\strona\index.php on line 2
kod wygląda tak:
<?php $password = sha1($_POST['pass']); $zapytanie = "select id from klienci where login = '".$konto."' and haslo = '".$password."'"; $wynikowo = $db->query($zapytanie); $ile = $wynikowo->num_rows; $id = $wynikowo; if ($ile>0) { $_SESSION['user_id']=$id; $_SESSION['login']=$konto; exit; } else { exit; } } ?> <form action="?p=login" method="post"> <strong>Nazwa konta:</strong><input name="uzytkownik" type="text" value="" /><br> <strong>Haslo:</strong><input name="pass" type="password" value="" /><br> <input type="submit" value="Zaloguj" /> </form>
W lini drugiej w index.php includuje połączenie z bazą mysql.
Z góry dziękuję za pomoc.