Question

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Question

kvarnerexpress
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.

 

 

 


Reply

mobious
you should use the GET method. redirect it like this.

first.install.screen.php?lang=en

Reply

webaurores
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

Reply

mobious
looks like you just need to pick from to solutions. being able to pick a language through a form or link. biggrin.gif

Reply

Spectre
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.

Reply

beeseven
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']; ?>">

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics
Looking for question

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for question

*MORE FROM TRAP17.COM*
advertisement



Question



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE