Hi,on my website, I want to have a drop down menu where you can select English or French...Then as soon as you make your choice, it ads a cookie with the value of your choice (so if you come back later it's the good language) and it reloads the page with the good language.But I don't know why, when my page is, for example in English, and I select French, the page reloads but it's in English. But if I reload the page manually then, it will be in French. I hope I was clear...Please help me out with this one. Here's my code...
///////////////// The form ////////////////<div style="color:#f2c114; float:right; position:relative; right:2%;"><form method="post" name="changelang" action="<?php cookie() ?>" style="padding:0; margin:0;">Language: <select name="lang" onChange="submit()" style="font-size:100%"> <option value="no" selected="selected"><u>Select</u></option> <option value="en">English</option> <option value="fr">Français</option>'; </select></form></div>//////////////////////////// The cookie() function////////////////////////////function cookie(){if ($_COOKIE['lang'] == ""){ setcookie("lang", "en", time()+70000);}if (isset($_POST['lang'])){if ($_POST['lang'] == "fr") { setcookie("lang", "fr", time()+70000); }else if ($_POST['lang'] == "en") { setcookie("lang", "en", time()+70000); }}}////////////////////// The index page//////////////////////<?phpif ($_COOKIE['lang'] == "" || $_COOKIE['lang'] == "en"){ require("forums/SSI.php"); require("header.php"); require("rightsidebar.php"); require("content.php"); require("footer.php");}if ($_COOKIE['lang'] == "fr"){ require("forums/SSI.php"); require("header.php"); require("rightsidebar.php"); require("contenu.php"); require("footer.php");}?>
Thanks a lot.