Page 1 of 1

Select Language [select form]

Posted: Fri Feb 20, 2009 5:33 pm
by Draco_03
Hi, It's been a while since I touched php.. so forgive my noobness.

I want a simple redirect depending on the value of the select.
if french / if english meta refresh to this url.

The form

Code: Select all

Language : 
    <form action="<?php echo $PHP_SELF;?>" method="post">
    <select name="lang" onchange="this.form.submit()">
        <option value="english">English</option>
        <option value="francais">Fran&ccedil;ais</option>
    </select>
    </form>
 
the php, I get the logic just cant put it in code, I guess the first problem is that by default, the value will be set to english, so I have to check what is the value

Code: Select all

if(isset($lang)){
if its english I have to make sure it has been switched from a french page meaning the value was french before...but not sure how to do that.

any help would be welcome.
my actual code (obviously not working) is this

Code: Select all

 
$lang=$_REQUEST['lang'];
if($lang='francais'){
print "<meta http-equiv='refresh' content='0; url=http://my-url-here.php'>";
}
 

Re: Select Language [select form]

Posted: Fri Feb 20, 2009 7:58 pm
by LanceEh
There is an answer to this, I would just have to think really hard.

Re: Select Language [select form]

Posted: Sat Feb 21, 2009 10:07 pm
by LanceEh
Unless you have a default language on the page (one that is always default), you must specify a language using the url.