Hi guys
Just wondering if you could help me out a little maybe.
I have a site which I am trying to have translated into different languages. I have the base code done and the function and it's all working well on my testing server which has php_register_globals on so that i can test... i.e. setlang.php?langid=1 and setlang.php?langid=2.
I haven't done any scripting for yeeeears so I'm still in PHP4 days when this option was on. However everything is now PHP5 so I can't simply insert an image of a UK flag and link it to "setlang.php?langid=1" and a german flag and link it to "setlang.php?langid=2" etc. anymore.
I've got my little flags inserted as input buttons at the moment.
<form name="setlang" method="post" action="setlang.php"><input type="image" src="images/ukflag.gif" alt="English (UK)" name="lang_en"> <input type="image" src="images/deflag.gif" alt="Deutsch" name="lang_de">
Then in my php script for setlang.php i have:
include("db.php");
include("inc/auth.php");
include("inc/functions.php");
if ($_POST['lang_en']==true) { // if they've pressed the england flag
translate("1","12"); // says "you've selected english"
}
else if ($_POST['lang_de']==true) { // if they've pressed the german flag
translate("2","12"); // says "Sie haben Ihre Sprache als 'deutsch' gewaehlt"
}
else {
translate("1","2"); // says "You didn't select a language"
}
The "translate" function is something I've put together that puts the phrase in the selected language. The site is pretty much based around this 'translate' function and it works fine.
It's just I'm having troubles, as when I click on one of the flags, it always displays the "you didn't select a language" error. So I'm wondering how I'm supposed to allow people to click the england flag and it says "you've selected english".
Also, if they do this, is the only way for me to pass this information from page to page without forms, through cookies? So for example, once I'm able to get the above part working, I'd then need to set a cookie to store that this language had been selected in order that when it's redirected to the homepage, it has been translated into the selected language?
Regards & thanks in advance
Carl