Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] Problem z level'em dla uzytkownika
Robert
post 18.07.2003, 22:31:01
Post #1





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 2.05.2003

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


Chcialbym by ktos sprawdzil mi moj kod bo gdzies jest blad ale nie wiem gdzie. Kod odpowiada za poziom dostepu. W pliku z userami jest zmienna $lev = "3" - dla administratora.
[php:1:6a2f8ce3e7]<?php if(session_is_registered("log")){
if($lev == "3") {
?>
Witaj [<font color="#888888"><?=$_SESSION["log"];?></font>]
<?php }
}?>[/php:1:6a2f8ce3e7]

fragment loginu bez formularza. Formularz znajduje sie w tym samym pliku[php:1:6a2f8ce3e7]<?php
if(!empty($_POST)) {
if(file_exists('includes/users/'.$_POST['login'].'.dat')) {
include('includes/users/'.$_POST['login'].'.dat');
if(isset($log) && isset($pass) && isset($lev)) {
if($pass = $_POST['password']) {
session_register('log');
header('location: index.php?page=download&'.SID);
exit();
} else {
echo 'Nieprawid&sup3;owy login!'; }
}
}
}
?> [/php:1:6a2f8ce3e7]

Bede wdzieczny za pomoc.

Pozdrawiam
Go to the top of the page
+Quote Post
eS...
post 21.07.2003, 21:01:02
Post #2





Grupa: Zarejestrowani
Postów: 367
Pomógł: 2
Dołączył: 4.03.2003
Skąd: C:/Windows/Temp

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


[php:1:5b4a105335]

<?php
if(session_is_registered("log"))
{
if($lev == "3") {

echo " Witaj [<font color="#888888">$_SESSION['log'] </font>] ";
}
}
?>
[/php:1:5b4a105335]

nie wiem powinno byc dobrze jak nie to pisz




?>[/php]
Go to the top of the page
+Quote Post
Robert
post 21.07.2003, 21:27:39
Post #3





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 2.05.2003

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


Tak to jest dobrze juz doszedlem do tego w dokladnie identyczny sposob.....:)Tylko brakuje includa...
[php:1:4b0ccd8261]<?php if(session_is_registered("log")){
include("includes/users/".$_SESSION["log"].".dat");
if($lev == "3") {
echo "<div align='right'>[<a href='index.php?page=admin' class='admin'>admin
panel</a>]</div>";

}
}

?>[/php:1:4b0ccd8261]
Go to the top of the page
+Quote Post
eS...
post 21.07.2003, 21:37:06
Post #4





Grupa: Zarejestrowani
Postów: 367
Pomógł: 2
Dołączył: 4.03.2003
Skąd: C:/Windows/Temp

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


heh dopiero zaczynam z php, ale 8)
Pozdro
Go to the top of the page
+Quote Post
DeyV
post 21.07.2003, 21:43:41
Post #5





Grupa: Zarząd
Postów: 2 277
Pomógł: 6
Dołączył: 27.12.2002
Skąd: Wołów/Wrocław




Cytat
Przy użyciu $_SESSION (lub $HTTP_SESSION_VARS) nie powinno się używać session_register(), session_is_registered() i session_unregister().  


--------------------
"Niezależnie od tego, jakie masz osiągnięcia, ktoś Ci pomaga..."
Go to the top of the page
+Quote Post
Robert
post 21.07.2003, 22:05:21
Post #6





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 2.05.2003

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


$_POST moze byc questionmark.gif
Go to the top of the page
+Quote Post
spenalzo
post 21.07.2003, 22:37:14
Post #7





Grupa: Zarejestrowani
Postów: 2 064
Pomógł: 1
Dołączył: 22.01.2003
Skąd: Poznań

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


Cytat
$_POST moze byc questionmark.gif

Nie za bardzo rozumiem pytania...


--------------------

Go to the top of the page
+Quote Post
Robert
post 21.07.2003, 22:52:56
Post #8





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 2.05.2003

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


Cytat
Cytat

Przy użyciu $_SESSION (lub $HTTP_SESSION_VARS) nie powinno się używać session_register(), session_is_registered() i session_unregister().  


Mam na mysli czy $_POST moze byc zamiast $_SESSION, jestem jeszcze na 1 levelu w php wiec moge bredzic smile.gif
Go to the top of the page
+Quote Post
spenalzo
post 21.07.2003, 22:56:43
Post #9





Grupa: Zarejestrowani
Postów: 2 064
Pomógł: 1
Dołączył: 22.01.2003
Skąd: Poznań

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


Tu chodzi o to, że jeżeli zapisujesz dane do sesji przez tablicę $_SESSION (lub $HTTP_SESSION_VARS) to nie jest zalecane np. sprawdzanie czy zmienna zostąła zarejestrowaa przez funkcję session_is_registered("zmienna"), ale przez !empty($HTTP_SESSION_VARS["zmienna"]).
Tak samo z usuwanieM: zamiast session_unregister("zmienna") użyj unset($HTTP_SESSION_VARS["zmienna"])
itd itp


--------------------

Go to the top of the page
+Quote Post
KaMeLeOn
post 21.07.2003, 22:57:34
Post #10





Grupa: Zarejestrowani
Postów: 680
Pomógł: 0
Dołączył: 1.10.2002
Skąd: Wrocław

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


Cytat
Mam na mysli czy $_POST moze byc zamiast $_SESSION, jestem jeszcze na 1 levelu w php wiec moge bredzic smile.gif

Obowiązkowa lektura...
http://pl.php.net/register_globals
http://pl.php.net/variables.predefined


--------------------
"Czerp z innych, ale nie kopiuj ich. Bądź sobą." Michel Quoist
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.07.2025 - 23:51