Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Question

Recommended Posts

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.

Share this post


Link to post
Share on other sites

$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:

<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

Share this post


Link to post
Share on other sites

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:

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.

Share this post


Link to post
Share on other sites

I agree that you could use $_GET. You could have a form that's like this:

<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:
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:
<a href="somethingelse.php?lang=<?php echo $_GET['lang']; ?>">

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.