|
|
|
|
![]() ![]() |
May 2 2005, 11:10 PM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 407 Joined: 13-December 04 Member No.: 2,696 |
I am rewriting a PHP install script. The first thing the user sees is an option to choose language. There are 3 languages Danish, English and German. I have 3 language files with variables with assinged values like this:
PHP Code: $help="Help"; When you choose a language, say, English the page jumps to a file with this script: PHP Code: session_start(); header("Cache-control: private"); // IE 6 Fix. $name = $_POST['language']; $_SESSION['lang'] = $name; if($_SESSION['lang']=='dan'){ include "../instlang/install.language.danish.php"; } if($_SESSION['lang']=='eng'){ include "../instlang/install.language.english.php"; } if($_SESSION['lang']=='ger'){ include "../instlang/install.language.german.php"; } ?> When your choise of language has been determined, your supposed to go to the first install screen. Qustion: How do I via the session tell the first install screen what kind of language it should include and shoud I direct the user to the first install screen via a header? Thank you. |
|
|
|
May 3 2005, 03:31 AM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 113 Joined: 14-January 05 From: Philippines Member No.: 3,271 |
you should use the GET method. redirect it like this.
first.install.screen.php?lang=en |
|
|
|
May 4 2005, 07:13 AM
Post
#3
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: Members Posts: 47 Joined: 26-December 04 From: mdeo.uy | theBestCityOfTheWorld | dontCome Member No.: 2,956 |
QUOTE $name = $_POST['language']; you are using $_POST, so you have to either change $_POST into $_GET or use a form instead a link to choose the language. fo example, if you want to choose the lang with a form, you may write: CODE <form action="first.install.screen.php" method="post" name="langForm"> <p> <input type="radio" name="language" value="dan" />Danish<br /> <input type="radio" name="language" value="ger" />Germany<br /> <input type="radio" name="language" value="eng" />English<br /> </p> </form> if i understood your question right, this sould work |
|
|
|
May 9 2005, 08:16 AM
Post
#4
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 113 Joined: 14-January 05 From: Philippines Member No.: 3,271 |
looks like you just need to pick from to solutions. being able to pick a language through a form or link.
|
|
|
|
May 24 2005, 03:19 AM
Post
#5
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 874 Joined: 30-July 04 Member No.: 246 |
Using the $_SESSION variable is fine and workable. Just note that you need to include session_start(); within each script that will access that session information before attempting to retrieve values from the array.
So for example, in every other script that is used externally thereafter: CODE session_start(); $lang = $_SESSION['lang']; On another note, using the include() function is more or less the equivalent of taking the data from the specified file, and placing it in the script at hand; which means that if the file being called in the include() function is a PHP script, it will have access to all of the existing variables, including $_POST; so, for example, '/instlang/install.language.danish.php' would be able to retrieve $_POST['language']. I think that's sort of what you're asking. |
|
|
|
May 25 2005, 12:51 AM
Post
#6
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 629 Joined: 26-February 05 Member No.: 3,995 |
I agree that you could use $_GET. You could have a form that's like this:
CODE <form method="get" action="something.php"> //method="get" adds the values of the inputs to the url <input type="radio" name="lang" value="danish"> Dansk <input type="radio" name="lang" value="german"> Deutsch <input type="radio" name="lang" value="english"> English //3 radio buttons with the languages <input type="submit" name="submit" value="Read File"> </form> Then in the PHP file: CODE if($_GET['lang'] == "danish") { include 'danish.php'; } elseif($_GET['lang'] == "german") { include 'german.php'; } elseif($_GET['lang'] == "english") { include 'english.php'; } If you have any links, you should just put this: CODE <a href="somethingelse.php?lang=<?php echo $_GET['lang']; ?>"> |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
Lo-Fi Version | Time is now: 7th October 2008 - 04:21 AM |