Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Sesje
-Wieviór-
post
Post #1





Goście







Mam taki skrypcik z logowaniem i sesjami, nadeslany mi przez kolege.

config.php
[php:1:8a0e1bf533]
<?php
session_start();
ob_start();
mysql_connect('localhost','xxx','xxx');
mysql_select_db('typer');
?>
[/php:1:8a0e1bf533]


login.php
[php:1:8a0e1bf533]<?php
include('config.php');
if(isset($_POST[login]) && isset($_POST[haslo])){
$query = "SELECT * FROM uzytkownicy WHERE login='$_POST[login]'";
$res1 = mysql_query($query);
$result = mysql_fetch_array($res1, MYSQL_ASSOC);
if($result[haslo] == crypt ($_POST[haslo], $result[haslo])){
$_SESSION = $result;
$_SESSION[zalogowany] = true;
header("Location: loggedin.php");
} else { header("Location: logowanie.php?msg=".urlencode('Niewła&para;ciwy login lub hasło')); }
} else { header("Location: logowanie.php"); }
?>[/php:1:8a0e1bf533]


logoff.php
[php:1:8a0e1bf533]<?php
include('onfig.php');

unset($_SESSION[login]);
unset($_SESSION[haslo]);

header("Location: logowanie.php?msg=".urlencode('Wylogowano.'));
?>[/php:1:8a0e1bf533]


loggedin.php
[php:1:8a0e1bf533]<?php
include('config.php');
include('auth.php');
echo 'udalo sie';
?>[/php:1:8a0e1bf533]


logowanie.php

[php:1:8a0e1bf533]<?php
<html>
<head>
</head>
<body>
<form action="login.php" method=POST><table border=0 class=ramka width=331 cellpadding=2>
<td><?php if($_GET[msg]) echo "<tr><td colspan=2>$_GET[msg]</td></tr>"; ?> <tr><td>Login: </td><td><input type=login name=login size=20 class=input></td></tr><tr><td>Hasło: </td><td><input type=password name=haslo size=20 class=input></td></tr><tr><td colspan=2><input type=submit value="Zaloguj" class=input_shadowed> <input type=reset value="Resetuj" class=input_shadowed></td></tr></table></form>
</body>
</html>
?>[/php:1:8a0e1bf533]


auth.php
[php:1:8a0e1bf533]<?php
if($_SESSION[zalogowany]){} //nic nie rob jest zalogowany
else { header('Location: logowanie.php'); exit; } //jesli nie jest zalogowany przejscie do logowania
?>[/php:1:8a0e1bf533]

No i jak wpisuje dane w logowanie.php o tak jakby nic sie nie dzieje(biala strona), z kolei u mojego kolegi dziala... sad.gif
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 6)
Majdan
post
Post #2





Grupa: Zarejestrowani
Postów: 445
Pomógł: 0
Dołączył: 21.12.2003
Skąd: Tomaszów Lubelski

Ostrzeżenie: (10%)
X----


Sprawdź, czy masz register_globals ustawione na ON.


--------------------
Go to the top of the page
+Quote Post
-Wieviór-
post
Post #3





Goście







Mam na ON
Go to the top of the page
+Quote Post
scanner
post
Post #4





Grupa: Zarząd
Postów: 3 503
Pomógł: 28
Dołączył: 17.10.2002
Skąd: Wrocław




Przeniesione: Skrypty -> php


--------------------
scanner.info
Warto pamiętać: KISS, DRY
Go to the top of the page
+Quote Post
-Wieviór-
post
Post #5





Goście







Hallo!! Kto mi pomoze!! tongue.gif
Go to the top of the page
+Quote Post
scanner
post
Post #6





Grupa: Zarząd
Postów: 3 503
Pomógł: 28
Dołączył: 17.10.2002
Skąd: Wrocław




w każdym pliku w pierwsej linii daj[php:1:c9ff07aace]<?php
error_reporting( E_ALL );
?>[/php:1:c9ff07aace]i zobacz, czy nie ma błędów.


--------------------
scanner.info
Warto pamiętać: KISS, DRY
Go to the top of the page
+Quote Post
-Wieviór-
post
Post #7





Goście







logowanie.php:
Notice: Use of undefined constant msg - assumed 'msg' in c:usrkrasnalwwwtypowanielogowanie.php on line 9

Notice: Undefined index: msg in c:usrkrasnalwwwtypowanielogowanie.php on line 9


login.php:
to samo, bo to ta sama strony jakby


auth.php:
Notice: Use of undefined constant zalogowany - assumed 'zalogowany' in c:usrkrasnalwwwtypowanieauth.php on line 5

Notice: Undefined variable: _SESSION in c:usrkrasnalwwwtypowanieauth.php on line 5

Warning: Cannot modify header information - headers already sent by (output started at c:usrkrasnalwwwtypowanieauth.php:5) in c:usrkrasnalwwwtypowanieauth.php on line 6


logoff.php:
Notice: Use of undefined constant msg - assumed 'msg' in c:usrkrasnalwwwtypowanielogowanie.php on line 9


loggedin.php(niezalogowany):
Notice: Use of undefined constant msg - assumed 'msg' in c:usrkrasnalwwwtypowanielogowanie.php on line 9

Notice: Undefined index: msg in c:usrkrasnalwwwtypowanielogowanie.php on line 9
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 17:54