Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [Skrypt]Autoryzacja
Cr0n!x
post 16.06.2003, 21:26:31
Post #1





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 24.05.2003

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


Otoz mam taki skrypt :

[php:1:d5d4feefb1]
<?php
if (file_exists("rejestracja/users/".$HTTP_COOKIE_VARS['login'].".usr"))
{
require("rejestracja/users/".$HTTP_COOKIE_VARS['login'].".usr");
}
if ( ($HTTP_COOKIE_VARS['login']=="$login") && ($HTTP_COOKIE_VARS['pw']=="$password") )
{
echo "zalogowany";
}
else
{
echo "bledne info";
}

?>[/php:1:d5d4feefb1]


Zawsze jest sie zalogowanym tu . Jaki popelnilem blad?.
Go to the top of the page
+Quote Post
Cudi
post 16.06.2003, 21:43:08
Post #2


Administrator planeta/IRC


Grupa: Przyjaciele php.pl
Postów: 385
Pomógł: 0
Dołączył: 19.04.2003
Skąd: Zabrze

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


A zmienne $login i $password pochodzą z jakiegoś formularza czy ich wartości są przypisane gdzieś wyżej ?


--------------------
"Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning."
Cudi's devBlog
Go to the top of the page
+Quote Post
Cr0n!x
post 16.06.2003, 22:03:58
Post #3





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 24.05.2003

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


Login i password pochodza z pliku
Kod
require("rejestracja/users/".$HTTP_COOKIE_VARS['login'].".usr");


a w pliku sa tak zapisane

$zmienna = 'cos' ;
Go to the top of the page
+Quote Post
Seth
post 16.06.2003, 22:11:42
Post #4





Grupa: Przyjaciele php.pl
Postów: 2 335
Pomógł: 6
Dołączył: 7.03.2002

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


W takich chwilach przydal by sie debuger i brake-pointy winksmiley.jpg

Zrob tak:
Daj przed drugim if'em to:
[php:1:31070304d4]print 'cookie-login: '.$HTTP_COOKIE_VARS['login'].'<br />';
print 'cookie-pw: '.$HTTP_COOKIE_VARS['pw'].'<br />';
print '$login='.$login.'<br />';
print '$password='.$password.'<br />';[/php:1:31070304d4]
I sprawdz co wypisuje.
Go to the top of the page
+Quote Post
Cr0n!x
post 16.06.2003, 22:30:51
Post #5





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 24.05.2003

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


Dziwne... Nic sie nie pojawia...
Taki mam kod.

[php:1:8044319378]<?php

if (file_exists("rejestracja/users/".$HTTP_COOKIE_VARS['login_nastolatki'].".usr"))
{
require("rejestracja/users/".$HTTP_COOKIE_VARS['login_nastolatki'].".usr");
print 'cookie-login: '.$HTTP_COOKIE_VARS['login'].'<br />';
print 'cookie-pw: '.$HTTP_COOKIE_VARS['pw'].'<br />';
print '$login='.$login.'<br />';
print '$password='.$password.'<br />';
}

?>[/php:1:8044319378]
Go to the top of the page
+Quote Post
Seth
post 16.06.2003, 22:40:04
Post #6





Grupa: Przyjaciele php.pl
Postów: 2 335
Pomógł: 6
Dołączył: 7.03.2002

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


Juz chyba wiem o co chodzi, if powinien zawierac w sobie drugiego if'a. Powinno wygladac tak (+male kosmetyczne poprawki winksmiley.jpg)

[php:1:23e1c2d307]
if ( file_exists( 'rejestracja/users/'.$_COOKIE['login'].'.usr' ) )
{
require( 'rejestracja/users/'.$HTTP_COOKIE_VARS['login'].'.usr');

if ( ( $_COOKIE['login'] == $login ) && ( $_COOKIE['pw'] == $password ) )
{
echo 'zalogowany';
}
else
{
echo 'bledne info';
}
}[/php:1:23e1c2d307]

Sprawdz moze teraz bedzie dobrze ?
Go to the top of the page
+Quote Post
Cr0n!x
post 17.06.2003, 14:20:17
Post #7





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 24.05.2003

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


Nie wiem co jest ale teraz wogole sie nic nie wyswietla.
Go to the top of the page
+Quote Post
Cudi
post 17.06.2003, 15:44:04
Post #8


Administrator planeta/IRC


Grupa: Przyjaciele php.pl
Postów: 385
Pomógł: 0
Dołączył: 19.04.2003
Skąd: Zabrze

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


Nic sie nie wyświetla bo plik "rejestracja/users/".$HTTP_COOKIE_VARS['login_nastolatki'].".usr" nie istnieje...

Spróbuj najpierw tak (nad całym tym kodem):

[php:1:2bba9ce199]<?php
echo "rejestracja/users/".$HTTP_COOKIE_VARS['login_nastolatki'].".usr";
?>[/php:1:2bba9ce199]

i zobacz co sie wyświetli...


--------------------
"Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning."
Cudi's devBlog
Go to the top of the page
+Quote Post
Cr0n!x
post 17.06.2003, 16:51:52
Post #9





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 24.05.2003

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


Ale tak czy siak skrypt powinien wyswietlac czy zalogowany/nie zalogowany nawet jak plik nie istnieje.
Go to the top of the page
+Quote Post
Cr0n!x
post 17.06.2003, 22:34:25
Post #10





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 24.05.2003

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


Prosze odpowiedzcie cos, jest mi to bardzo potrzebne.
Go to the top of the page
+Quote Post
BzikOS
post 20.06.2003, 17:14:31
Post #11





Grupa: Przyjaciele php.pl
Postów: 660
Pomógł: 0
Dołączył: 28.08.2002
Skąd: Starachowice

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


Spróbuj zmienić nazwy zmiennych, aby zmienne $login i $pw w pliku inaczej się nazywały niż te w cookies, np.

[php:1:2a1190de10]<?php
if($_COOKIE['cookie_login'] == $login && $_COOKIE['cookie_pw'] == $password)
echo 'zalogowany';
else
echo 'bledne info';
?>[/php:1:2a1190de10]
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: 23.06.2025 - 05:04