<?php
require ('../../smarty/Smarty-2.6.9/libs/Smarty.class.php');
require ('../inne/opcje.php'); // hasło
$smarty = new Smarty;
$smarty -> template_dir = '../inne';
$smarty -> compile_dir = '../inne/kopie';
$smarty -> assign ('TYTUL', 'Indeks administracji');
$smarty -> assign ('SLOWA_KLUCZOWE', '');
$smarty -> assign ('OPIS', '');
$smarty -> assign ('PREFIKS_URI', '../');
$smarty -> assign ('SZABLON', 'szablony/admin_index.tpl');
if ($_GET['akcja'] == 'wyloguj') {
if (isset ($_COOKIE['zalogowany'])) { unset ($_COOKIE['zalogowany']); $smarty -> assign ('NAZWA', 'wylogowany');
$smarty -> assign
('LINKI', array ('../index.php' => 'Powrót do bloga')); }
}
else {
if (isset ($_POST['zaloguj'])) { if ($_POST['haslo'] == $haslo) {
}
else {
$smarty -> assign ('NAZWA', 'zle_haslo');
}
}
if (isset ($_COOKIE['zalogowany'])) { $smarty -> assign ('NAZWA', 'zalogowany');
$smarty -> assign
('LINKI', array ('../index.php' => 'Powrót do bloga', 'index.php?akcja=wyloguj' => 'Wyloguj')); }
else {
$smarty -> assign ('NAZWA', 'formularz');
$smarty -> assign
('LINKI', array ('../index.php' => 'Powrót do bloga')); }
}
$smarty -> assign ('TYTUL_STRONY', 'Indeks administracji');
$smarty -> display('szablon.tpl');
?>
Heh

Oto formularz podszablon który includuję w smarty pod zmienną NAZWA
{if $NAZWA == "wylogowany"}
<p>Zostałeś wylogowany.
</p> {elseif $NAZWA == "zalogowany"}
<p>Jesteś zalogowany.
</p> {elseif $NAZWA == "zle_haslo"}
{else}
<form method="post" action="index.php"> Hasło:
<input type="password" name="haslo" /><input type="submit" name="zaloguj" value="Zaloguj!" /> {/if}
No więc po wpisaniu hasła jeszcze raz pokazuje formularz - nic się nie dzieje

Sprawdziłem czy ustawił cookie o nazwie zalogowany - NIE!
Za każdym razem pokazuje formularz logowania. Hmmmmm

Dzięki za pomoc
Ten post edytował Fipaj 12.05.2005, 13:52:12