Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Pomoc -logowanie i wylogowywanie z bazy
leszczyk
post 26.05.2009, 21:23:14
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 26.05.2009

Ostrzeżenie: (0%)
-----


Czy mógłby ktoś to wytłumaczyć?

<?PHP

function checkPass($user, $pass)

{
$userNameLength = strlen($user);
$userPassLength = strlen($pass);


if($userNameLength < 3 || $userNameLength > 20 ||
$userPassLength < 6 || $userPassLength > 40){
return 2; }

$db_handle = pg_connect("dbname = Biblioteka user = natalka password = zaq12wsx host = bazy.eti.pg.gda.pl");

$query = "SELECT COUNT(*) FROM Users WHERE Nazwa='$user' AND Haslo='$pass'";
if(!$result = pg_query($db_handle, $query)){
pg_close();
return 1;
}

if(!$row = @pg_fetch_row($result)){
pg_close();
return 1;
}

else{
if($row[0] <> 1){
pg_close();
return 2; }

else{

pg_close();
return 0;

}
}
}

session_start();
if(isSet($_SESSION['zalogowany'])){
header("Location: main.php");

}
else if(!isSet($_POST["haslo"]) || !isSet($_POST["user"])){
$_SESSION['komunikat'] = "Wpisz nazwę i hasło użytkownika:";
include('index.php');
}

else{
$val = checkPass($_POST["user"], $_POST["haslo"]);
if($val == 0){
$_SESSION['zalogowany'] = $_POST["user"];
header("Location: main.php");
}

else if($val == 1){
$_SESSION['komunikat'] = "Błąd serwera. Zalogowanie nie było możliwe.";
include('index.php');
}

else if($val == 2){
$_SESSION['komunikat'] = "Nieprawidłowa nazwa lub hasło użytkownika.";
include('index.php');
}

else{

$_SESSION['komunikat'] = "Błąd serwera. Zalogowanie nie było możliwe.";
include('index.php');
}
}

?>


czy include tylko wkleja zadany plik
co oznacza ten znak <>
jaką dokładnie funkcje pełni header
$_SESSION[''] czy moge dowolny ciąg znaków wklejać tu i jakie ma to znaczenia
nie bardzo rozumiem pogrubioną częśc
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
netvalue
post 26.05.2009, 21:26:46
Post #2





Grupa: Zarejestrowani
Postów: 199
Pomógł: 2
Dołączył: 9.06.2008

Ostrzeżenie: (0%)
-----


Leszczyku, polecam CI http://www.php.rk.edu.pl/w/p/podstawy-php/

Ten post edytował netvalue 26.05.2009, 21:27:24
Go to the top of the page
+Quote Post
mefju22
post 30.05.2009, 23:17:42
Post #3





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 30.05.2009

Ostrzeżenie: (0%)
-----


a czy kolege chodził na laborki z baz? zajrzyj do instrukcji.. tongue.gif
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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 06:48