Jump to content

Change Variable using Hyperlink


imperium2335

Recommended Posts

Hi,

 

Im trying to set something up where the user can choose a language using session and a hyperlink that changes the variable.

 

<?PHP

$_SESSION['lang'] = "En" ;

?>

 

So when they click, say french, the above var is now "Fr".

 

ive tried this: <a href="cake-photos.html?lang=Fr">French</a>

 

But it doesn't work. Please help.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/158355-change-variable-using-hyperlink/
Share on other sites

What's with the semi-colons in the cases?

session_start();
switch ($_GET['lang']) {
case 'Fr':
   $_SESSION['lang'] = "Fr";
   break;

case 'En':
default:
   $_SESSION['lang'] = "En";
}

Oops typo lol. Dunno why I did them all with a semi-colon and then with a colon for the default ??? lol

Thanks for your replys, this is what i used in the end:

session_start();

if(isset($_GET['lang'])) 

{

$_SESSION['lang'] = $_GET['lang'];

setlocale(LC_ALL, $_SESSION['lang']);

}

else

{

setlocale(LC_ALL, $_SESSION['lang']);

}



echo $_SESSION['lang'];

?>

I am unfamilier with setlocale though.

 

Out of interest, does anyone know the default font type Arabic users use?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.