Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php]Link a sesje
Robert
post 18.07.2003, 11:43:25
Post #1





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

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


Witam
Na stronie posluguje sie takimi linkami
Kod
<a href="index.php?page=admin">admin</a>
W momencie gdy mam ustawiona sesje w index.php to przy wywolaniu admina i przy logowaniu wyskakuje blad o zle podanym hasle. Lecz skrypt ten dziala na 100%. Moze byc to wina sesji??

Pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
zulus
post 18.07.2003, 11:55:52
Post #2





Grupa: Zarejestrowani
Postów: 225
Pomógł: 18
Dołączył: 30.06.2003
Skąd: Wrocław

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


:arrow: a możę by tak jakiś kod :?:
Go to the top of the page
+Quote Post
Robert
post 18.07.2003, 12:09:41
Post #3





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

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


To jest taki prosty skrypt logujacy[php:1:78758d1301]<?php
session_start();
$adres_strony = "index.php?page=admin";
if ($haslo == "" || $login == "")
{
echo "<form action=$adres_strony method=post><br>";
echo "Login: <input type=text name=login><br>";
echo "Haslo: <input type=password name=haslo><br>";
echo "<input type=submit value=Loguj>";
}

if ($haslo=="kolo" && $login=="admin")
{
echo "<div align=center><b>Panel Administracyjny</b></div><br><a href=index.php?page=form_aktual>Dodaj aktualizacja</a><br><a href=index.php?page=edit_aktual>Edytuj aktualizacje</a><br><br><a href=index.php?page=form_newsy>Dodaj newsa</a>
";
}

elseif ($haslo!="" || $login!="")
{
echo "Złe hasło i/lub login<br>
<a href=$adres_strony>Spróbuj ponownie</a>";
}
?>
[/php:1:78758d1301]
Go to the top of the page
+Quote Post
zulus
post 18.07.2003, 12:35:23
Post #4





Grupa: Zarejestrowani
Postów: 225
Pomógł: 18
Dołączył: 30.06.2003
Skąd: Wrocław

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


Przy takim skrypcie logowania nie potrzebne są sesje.
ąle jeżeli już chcesz to zarejetruj sobie login po poprawnym zalogowaniu jako zmienną sesyjną (np.: $login_sess) i potem przerób sobie istrukcję if mniej więcej w ten sposób:
[php:1:8c8897e40b]
<?php
session_start();
$adres_strony = "index.php?page=admin";
if (!$login_sess)
{
echo "<form action=$adres_strony method=post><br>";
echo "Login: <input type=text name=login><br>";
echo "Haslo: <input type=password name=haslo><br>";
echo "<input type=submit value=Loguj>";
}

if ($haslo=="kolo" && $login=="admin")
{
session_register("login_sess");
$login_sess = $login;
}
if ($login) {
echo "<div align=center><b>Panel Administracyjny</b></div><br><a
href=index.php?page=form_aktual>Dodaj aktualizacja</a><br><a
href=index.php?page=edit_aktual>Edytuj aktualizacje</a><br><br><a
href=index.php?page=form_newsy>Dodaj newsa</a>
";
}

elseif ($haslo!="" || $login!="")
{
session_unregister(login_sess);
echo "Złe hasło i/lub login<br>
<a href=$adres_strony>Spróbuj ponownie</a>";
}

?>[/php:1:8c8897e40b]
Go to the top of the page
+Quote Post
Robert
post 18.07.2003, 13:04:16
Post #5





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

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


Mam takie pytanko:
W momencie gdy mam ustawiona sesje w index.php to przy wywolaniu strony admina tj
Kod
<a href="index.php?page=admin">linl</a>

sesja przechodzi do strony admin.php3 questionmark.gif
Bo w momencie gdy dodalem sesje na stronie do logowania uzytkownkikow ten skrypt przestal dzialac....
Pozdrawiam
Go to the top of the page
+Quote Post
HaRy
post 18.07.2003, 16:23:23
Post #6





Grupa: Zarejestrowani
Postów: 152
Pomógł: 0
Dołączył: 15.05.2002
Skąd: Łódź

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


generalnie powinna przejsc ...
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: 19.07.2025 - 19:43