gasma1975 Posted January 15, 2008 Share Posted January 15, 2008 Hi, I'm designing a multi language Website french/english. I have a dropdown with a button that will SET a global variable. Value 1 = English and 2 = French, the default language is value 1 (english) But when the person switch the language I will also Set the corresponding value in the dropdown and I will translate the website content. On my index.php page everything is fine. But if the person has selected the french language, when he's redirected to another page, the page is in english not french. I have to select the drop down language on each page ! very annoying. How can make it constant ? This is the code that will handle the drop down selection lnaguage if(isset($_POST['ChangeLanguage'])) { unset($_SESSION['lang']); $lang= $_POST['lang']; if ($lang == 1) { //English picked, load English page $_SESSION['lang']=1; } elseif ($lang == 2) { //French picked, load French page $_SESSION['lang']=2; } } This is the button and dropdown <form method="post" class="searchform" action="#"> <div align="right"> <select name="lang"> <option value= "1" <?php if($_SESSION['lang']==1){echo 'selected="selected"';} ?>> English</option> <option value= "2" <?php if($_SESSION['lang']==2){echo 'selected="selected"';} ?> >Francais</option> </select> <input type="submit" name="ChangeLanguage" value="Go" /> </div> </form> thank you, gasma1975 Quote Link to comment https://forums.phpfreaks.com/topic/86072-solved-problem-with-keeping-a-_session-variable-language/ Share on other sites More sharing options...
MikeDXUNL Posted January 15, 2008 Share Posted January 15, 2008 make sure session_start(); is at the top of each page Quote Link to comment https://forums.phpfreaks.com/topic/86072-solved-problem-with-keeping-a-_session-variable-language/#findComment-439522 Share on other sites More sharing options...
gasma1975 Posted January 15, 2008 Author Share Posted January 15, 2008 Yes it is, first place in <body> ! Quote Link to comment https://forums.phpfreaks.com/topic/86072-solved-problem-with-keeping-a-_session-variable-language/#findComment-439531 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.