Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem ze smarty, tym razem formularze
Legro
post
Post #1





Grupa: Zarejestrowani
Postów: 233
Pomógł: 3
Dołączył: 18.07.2005

Ostrzeżenie: (40%)
XX---


Mam taki skrypt w php do logowania admina:

  1. <?php
  2.  
  3. require_once ('../config.php');
  4.  
  5. if ( !empty ( $_POST['login'] ) && !empty ( $_POST['haslo'] )) {
  6.  
  7. foreach ( $admins as $l => $h ) {
  8.  
  9. if ( $l == $_POST['login'] ) {
  10.  
  11. if ( $h == $_POST['haslo'] ) {
  12.  
  13. $_SESSION['Admin'] = $_POST['login'];
  14. }
  15.  }
  16. }
  17.  }
  18.  
  19.  
  20. if ( ! $_SESSION['Admin'] ) {
  21.  
  22. echo '<form action="index.php" method="post">';
  23. echo '<input type="text" name="login"><br />';
  24. echo '<input type="password" name="haslo"><br />';
  25. echo '<input type="submit">';
  26. echo '</form>';
  27.  
  28. } else {
  29.  
  30. header ("Location: admin.php");
  31.  
  32. }
  33.  
  34. ?>


Przerobilem go sobie na smarty:

  1. <?php
  2.  
  3. require_once ('../config.php');
  4. require_once ( SMARTY_DIR . 'Smarty.class.php' );
  5.  
  6. if ( !empty ( $_POST['login'] ) && !empty ( $_POST['haslo'] )) {
  7.  
  8. foreach ( $admins as $l => $h ) {
  9.  
  10. if ( $l == $_POST['login'] ) {
  11.  
  12. if ( $h == $_POST['haslo'] ) {
  13.  
  14. $_SESSION['Admin'] = $_POST['login'];
  15. }
  16.  }
  17. }
  18.  }
  19.  
  20. /******* TUTTAJ *******/
  21.  
  22.  
  23. if ( ! $_SESSION['Admin'] ) {
  24.  
  25. echo '<form action="index.php" method="post">';
  26. echo '<input type="text" name="login"><br />';
  27. echo '<input type="password" name="haslo"><br />';
  28. echo '<input type="submit">';
  29. echo '</form>';
  30.  
  31. } else {
  32.  
  33. header ("Location: admin.php");
  34.  
  35. }
  36.  
  37. $smarty->display('adm_login.tpl');
  38.  
  39. ?>


ale teraz mam problem z formularzem.

jak zrobic aby go nie bylo w kodzie php tylko zeby byl w tpl ?
jak go przeniose do pliku adm_login.tpl to nie dziala formularz.

w drugim kodzie od linijki /******* TUTTAJ *******/ jest takie cos:

- jezeli zmienna $_SESSION['Admin'] nie istnieje, wyswietlamy formularz, a jezeli istnieje to przekierowyje do pliku admin.php

jak to zrobic w smartach??

pozdrawiam, juz sie mecze z tym od tego czasu jak skonczylem na konfiguracji sciezek do smarty winksmiley.jpg

Ten post edytował Legro 12.05.2006, 21:49:58


--------------------
nospor - jestem z Wami !!!
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 19.08.2025 - 21:59