Select Language [select form]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Select Language [select form]

Post 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'>";
}
 
User avatar
LanceEh
Forum Commoner
Posts: 46
Joined: Tue Feb 17, 2009 11:53 am
Location: Florida

Re: Select Language [select form]

Post by LanceEh »

There is an answer to this, I would just have to think really hard.
User avatar
LanceEh
Forum Commoner
Posts: 46
Joined: Tue Feb 17, 2009 11:53 am
Location: Florida

Re: Select Language [select form]

Post by LanceEh »

Unless you have a default language on the page (one that is always default), you must specify a language using the url.
Post Reply