ramzess Posted August 15, 2006 Share Posted August 15, 2006 Sorry guys, it probably is funny.... not to me thoughI have a very simple page based on html/css and some minor phpfirst page (lets say: www.name.com/index.php) contains simple text links (language selection).On top of it there is such php code:<?phpif ( $_COOKIE['LangCookie'] == eng)header("Location: lv.php");elseif ( $_COOKIE['LangCookie'] == ger)header("Location: ru.php");?>User selects link (representing his language) and gets to www.name.com/eng/index.phpwhere a cookie is written:<?php$language = 'eng';setcookie("LangCookie", $language, time()+60);?>Well I know that current time is set to 60sec's... that's for testing purposes...[b]Here is the problem:[/b]IF user has selected wrong language, and wants to get back to main page (language selection page),he cant, because php code at the start of it checks the cookie content and sends him backto page he selected first time, unless cookie has expired or is deleted from PC.Guys, IS there a possibility to get back to main page to reselect the language?Please, please, please... :'( Quote Link to comment Share on other sites More sharing options...
mb81 Posted August 15, 2006 Share Posted August 15, 2006 I would say this is more of a site design thing, but if you are looking for the php answer, here it is:Send a variable via GET in your request back to the homepage that designates that you are going to set the languageOn the homepage, check for that GET variable before redirecting anywhere.Typically, language change items are on every page, so like I said, this can also be fixed by designing a better UI and flow for your site. Quote Link to comment Share on other sites More sharing options...
DocSeuss Posted August 15, 2006 Share Posted August 15, 2006 Well at the top of your page you are checking if the cookie is set and if it is the user gets sent to the page. No way to prevent this if the cookie is set. You can set a link on those pages that would allow the user to click it which would take them to a page to delete the cookie then redirect to the lang selection page.. Quote Link to comment Share on other sites More sharing options...
ramzess Posted August 15, 2006 Author Share Posted August 15, 2006 [quote author=mb81 link=topic=104373.msg416290#msg416290 date=1155660224]I would say this is more of a site design thing, but if you are looking for the php answer, here it is:Send a variable via GET in your request back to the homepage that designates that you are going to set the languageOn the homepage, check for that GET variable before redirecting anywhere.Typically, language change items are on every page, so like I said, this can also be fixed by designing a better UI and flow for your site.[/quote]Thank you in advance.Hm... Thank you very much. Though I am not so sure on how to do that.Let's say I have a link on some of those language pages (let's say 'mainENG.php'), sending user back to main page. Ok?So where do I define this variable I have to send via GET? On the same page? Like:$noredirectvhat would be the value of it?and where would I put this GET? And how can I check for the GET variable on the language selection page, if code:<?phpif ( $_COOKIE['LangCookie'] == eng)header("Location: lv.php");elseif ( $_COOKIE['LangCookie'] == ger)header("Location: ru.php");?>is on thee very top of that page above <HTML> tag?Sorry, I must be stupid and sound just as annoying as all others who just start to get familiar with PHP. :( Quote Link to comment Share on other sites More sharing options...
ramzess Posted August 16, 2006 Author Share Posted August 16, 2006 Could at least somebody please show me how you must write this expression with $_GET?What is this variable I should send back to homepage? How?I believe on homepage these should be something like if isset $_GET and it's valuethen something happens.. but how.. :( Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 16, 2006 Share Posted August 16, 2006 this is an example to use $_GET ok.a link activate $_GET[code]<a href="what_ever.php?cmd=goit">my link</a>[/code]use the$_GET from the link to activate somethink.[code]<?phpif($_GET['cmd']=="gotit"){do somethink}?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.