Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wielojęzykowość + sesje + ciacho
pedro84
post
Post #1





Grupa: Nieautoryzowani
Postów: 2 249
Pomógł: 305
Dołączył: 2.10.2006

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


Witam!

Mam stronę językową, zrobioną w taki sposób:

index.php
  1. <?php
  2. require_once("langman.php");
  3. if(!SelectLanguage($_SESSION["lang"]))
  4. die("Error selecting language!");
  5. ?>



langman.php
  1. <?php
  2. $language = array();
  3.  
  4. function SelectLanguage($strLang)
  5. {
  6. global $language;
  7.  
  8. $inc = "en";
  9. switch(stripslashes($strLang))
  10. {
  11. case "de":
  12. $inc = "de";
  13. break;
  14.  
  15. case "en":
  16. $inc = "en";
  17. break;
  18.  
  19. case "pl":
  20. $inc = "pl";
  21. break;
  22.  
  23. default:
  24. $inc = "en";
  25. }
  26.  
  27.  
  28. include_once("languages/" . $inc . ".inc");
  29. if(isset($lang))
  30. {
  31. $language = $lang;
  32. return true;
  33. }
  34.  
  35. return false;
  36. }
  37.  
  38.  
  39.  
  40. ?>


setlang.php
  1. <?php
  2. $strLang = $_GET["lang"];
  3. $_SESSION["lang"] = stripslashes($strLang);
  4. header("Location: index.php"); //** redirect to where u want...
  5. ?>



Pytanie, jak dodać do tego wszystkiego ciacho, żeby system wysyłał ciacho i potem pobierał z niego informacje i języku danego odzwiedzającego?
Przy pierwszym wejściu na stronę pojawia się taki komunikat:
  1. <?php
  2. Notice: Undefined index: lang in c:easyphp1-8wwwindex.php on line 4
  3. ?>


Pozdrawiam
A.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
pedro84
post
Post #2





Grupa: Nieautoryzowani
Postów: 2 249
Pomógł: 305
Dołączył: 2.10.2006

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


Niestety nic mi to nie dało. Próbowałem już w ten sposób:

  1. <?php
  2. setcookie ("lang", $lang);
  3. ?>


Wywala coś takiego

  1. <?php
  2. Notice: Undefined variable: lang in c:easyphp1-8wwwindex.php on line 3
  3.  
  4. Warning: Cannot modify header information - headers already sent by (output started at c:easyphp1-8wwwindex.php:3) in c:easyphp1-8wwwindex.php on line 3
  5.  
  6. Notice: Undefined index: lang in c:easyphp1-8wwwindex.php on line 5
  7. ?>


Hmm. Ale jak zrobić to poprzez isset? Próbowałem na setki, nieudanych, sposobów. Isset ma być w pliku index.php czy setlang.php? Ehh coś mi nie idzie:(

Ten post edytował pedro84 28.11.2006, 14:42:58
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 28.09.2025 - 04:50