1st problem
I have a dynamic site where the pages are included in the index page dynamically in the following way:
$page = (empty($_GET["page"])) ? "home" : $_GET["page"];
$page = "folder/".basename($page).".php";
if (is_readable($page)) {
include($page);
} else {
echo 'Site doesn't exist!';
exit;
}
But there is also a language menu which changes the languages with another $_GET parameter:
<form name="switch" id="lang" action="" method="get">
<select name="multilingual" onchange="this.form.submit()">
<option value="lang_it">Italian</option>
<option value="lang_de" >German</option>
<option value="lang_en">English</option>
</select>
</form>
if(!isset ($_COOKIE['multilingual'])){
$lingua = null;
}else{
$lingua = $_COOKIE['multilingual'];
}
if(isset($_GET['multilingual'])){
$lingua = $_GET['multilingual'];
$_SESSION['multilingual'] = $lingua;
setcookie('multilingual', $lingua, time() + (3600 * 24 * 30));
}
switch($lingua){
case 'lang_it': include_once('file_it.php'); break;
case 'lang_de': include_once('file_de.php'); break;
case 'lang_en': include_once('file_en.php'); break;
default: include_once('file_it.php'); break;
}
The second $_GET parameter is passed to the URL but on the pages it will redirect me always to the default home page.
How to change the language without beiing redirected to the home page? In other words, ho to change the language and stay on the same page?
2nd problem
Is it possibile to change the lang_it, lang_de, lang_en parameter in the URL to get redirected to the current language of the page. If this will happen, how to change the language switcher when the page changes to another language?