View Full Version : language cookie
chechu
01-14-2007, 09:17 PM
Hey,
On lots of sites, at your first visit, you have to chose your language. That information is stored in/by a cookie, so the next time you visit that site, you are immediately forwarded to the language you choose.
How does such a cookie look like ? Is this php or Java ?
mburt
01-14-2007, 09:40 PM
PHP or Java*Script.
PHP is super easy to make cookies...
See here:
setcookie(cookiename,data,time()+3600);
and to retrieve like so
$_COOKIE[cookiename];
joycie
01-15-2007, 12:18 AM
May I know if it is possible to create cookies so that I could track what people are doing on my site, such as downloading photos, songs, the page they view etc?
tech_support
01-15-2007, 01:18 AM
On every page,
$cookiename = "tracker";
$olddata = $_COOKIE[$cookiename];
$newdata = "Visited page " . $_SERVER['PHP_SELF'];
$data = $olddata . $newdata;
setcookie($cookiename,$data,time()+3600);
thetestingsite
01-15-2007, 01:21 AM
setcookie(cookiename,data,time()+3600);
This should actually be like this:
setcookie($cookiename,$data,time()+3600);
tech_support
01-15-2007, 01:23 AM
Oops... My bad. :)
Fixed now.
joycie
01-15-2007, 01:27 AM
Many thanks for both your help.
After that, how do I retreive the record to check?
Is it possible to tell the location (such as ip) of each person?
tech_support
01-15-2007, 01:32 AM
http://www.dynamicdrive.com/forums/showpost.php?p=62837&postcount=18
joycie
01-15-2007, 01:45 AM
Thanks but is there one that can combine with the above code?
I only need to know the IP of the person.
tech_support
01-15-2007, 01:52 AM
$ip = $_SERVER["REMOTE_ADDR"]
thetestingsite
01-15-2007, 02:37 AM
$ip = $_SERVER['HTTP_HOST'];
The above would get the host name not the ip address. If you wanted just the ip, you would have to use $_SERVER["REMOTE_ADDR"];
chechu
01-15-2007, 08:21 AM
So, to get back to the first question; to remember a language choice, I just place the following into the choosen language ? Correct ?
$cookiename = "tracker";
$olddata = $_COOKIE[$cookiename];
$newdata = "Visited page " . $_SERVER['PHP_SELF'];
$data = $olddata . $newdata;
setcookie($cookiename,$data,time()+3600);
chechu
01-15-2007, 08:22 AM
And does the above redirect at next visit ?
joycie
01-15-2007, 01:38 PM
chechu, so sorry to interrupt again.
Thanks to tech_support and thetestingsite for your input.
May I know after creating the cookies, how to I test and view the result?
thetestingsite
01-15-2007, 04:04 PM
So, to get back to the first question; to remember a language choice, I just place the following into the choosen language ? Correct ?
$cookiename = "tracker";
$olddata = $_COOKIE[$cookiename];
$newdata = "Visited page " . $_SERVER['PHP_SELF'];
$data = $olddata . $newdata;
setcookie($cookiename,$data,time()+3600);
The above would save a cookie for the pages that the user has visited. To make the language one, simply change a few items.
$cookiename = "lang";
$data = $languageChoice; //the variable for the language that was choosen.
setcookie($cookiename, $data, time()+3600);
As for joycie, you could use the following to check the data.
$theCookie = $_COOKIE['tracker']; //change "tracker" to your saved cookiename.
echo $theCookie; //echos the data stored in the cookie.
Hope this helps both of you.
chechu
01-16-2007, 09:26 AM
Sorry, but I'm really no good at php.
What goes on the selection page, and what goes on the selected page ? In the <head> ? Do I need to put <!? php somewhere as well ?
Questions from a dummie ...
thetestingsite
01-17-2007, 02:21 AM
Lets make a simple file (call it langTest.php), in this file we will place the following code:
<?php
$homepage = 'http://'.$_SERVER["HTTP_HOST"].'/';
if ($_REQUEST['act'] == "setLang") {
//check to see if the form has been submitted!
if ($_REQUEST['lang'] == "") {
header('Location: '.$_SERVER["PHP_SELF"]);
//if language selection is empty, redirect to form!
}
else {
//if language was selected, save it in a cookie, then redirect to appropriate page!
$lang = $_REQUEST['lang'];
setcookie("language, $lang, time()+3600);
header('Location: '.$homepage.$lang);
}
}
else {
//if form has not been submitted
if (@$_COOKIE['language'] != "") {
/* check to see if language cookie is empty. If not, redirect to appropriate page. */
header('Location: '.$homepage.$_COOKIE["language"]);
}
else {
//if cookie is empty, display form
?>
<html>
<head>
<title>Language Cookie Test</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="act" value="setLang">
<select name="lang">
<option value="en">English</option>
<option value="sp">Spanish</option>
<option value="ru">Russian</option>
</select>
<input type="submit" value="Set Language">
</form>
</body>
</html>
<?php
}
}
?>
That should do it, let me know if you need any more help.
joycie
01-24-2007, 12:14 AM
Would appreciate if someone could help:
Tested using the above tracking php codes but returned with error--
Parse error: syntax error, unexpected T_STRING on line 7
<?php
$cookiename = "tracker";
$olddata = $_COOKIE[$cookiename];
$newdata = "Visited page " . $_SERVER['PHP_SELF'];
$data = $olddata . $newdata;
$ip = $_SERVER["REMOTE_ADDR"]
setcookie($cookiename,$data,time()+3600);
?>
<html>
<head>
<title>Test</title>
</head>
<body>hello
</body>
</html>
BLiZZaRD
01-24-2007, 02:30 AM
unless I am mistaken, and I might be, I never really knew much about php and I am forgetting more everyday...
$ip = $_SERVER["REMOTE_ADDR"]
is missing it's semicolon *;* at the end, and the parse error is coming from trying to combine the last two lines into one, as there is no separator.
joycie
01-24-2007, 01:52 PM
Thanks to BLiZZaRD.
I use the codes below and when I go to the page http://domain.com/tracker.php, the page shows this message "Visited page /tracker.php"
<?php
$cookiename = "tracker";
$olddata = $_COOKIE[$cookiename];
$newdata = "Visited page " . $_SERVER['PHP_SELF'];
$data = $olddata . $newdata;
$ip = $_SERVER["REMOTE_ADDR"]
setcookie($cookiename,$data,time()+3600);
?>
<?php
$theCookie = $_COOKIE['tracker'];
echo $theCookie; //echos the data stored in the cookie.
<html>
<head>
<title>Test</title>
</head>
<body></body>
</html>
Is this the correct way to call? Why is my IP and date visited not shown on the page? Pardon me for my query. I am a newbie in PHP. Thanks for any help.
thetestingsite
01-26-2007, 03:31 PM
You would have to do something like the following in order to get it to display right:
<?php
$cookiename = "tracker";
$olddata = $_COOKIE[$cookiename];
$newdata = "Visited page " . $_SERVER['PHP_SELF'];
$data = $olddata . $newdata;
$ip = $_SERVER["REMOTE_ADDR"];
setcookie($cookiename,$data,time()+3600);
$theCookie = $_COOKIE['tracker'];
?>
<html>
<head>
<title>Test</title>
</head>
<body>
<?php
echo $theCookie; //echos the data stored in the cookie.
echo 'IP Address: '.$ip; //echos IP Address found by REMOTE_ADDR above
?>
</body>
</html>
Hope this helps.
BLiZZaRD
01-27-2007, 04:58 PM
Aye, looks good to me, and just to explain incase you couldn't tell by test's script there, in your original code you were calling the variable $theCookie;
Yet in your script definitions "theCookie" was never defined. So basically you were giving your scripts names for all it's apples then asking it to show you an orange.
Just notice how test's script defines what $theCookie actually is, so when it is called for in the echo' the script KNOWS what to display :)
thetestingsite
01-27-2007, 05:02 PM
Thanks for explaining it for me Blizzard, I was looking at it last night and thought it could use some explaining, but never got around to it.
BLiZZaRD
01-28-2007, 05:29 PM
No problem buddy, you do it for me as well. Team work and all that. Plus later when I have the same problems cause I am so forgetful, I can look at my own posts and answer myself...
ROTF!
joycie
01-29-2007, 01:41 PM
Many thanks to both thetestingsite and BLiZZaRD for your time and patience.
I could now view my own IP when I access the php file online.
If I want to keep a record of what people do when they visit a webpage of my site, say downloading picture or songs, etc, may I know how I could modify the script so that only I (and not others) could view the IPs of people who visit my site and what he/she did on my site?
Any help would be greatly appreciated.
BLiZZaRD
01-29-2007, 01:56 PM
That is a tricky question.
Yes there are ways to make it so you can find and follow an IP around your site. I am not so sure you will be able to "see" what they are doing.
About the best you could do is see which pages they go to and for how long.
One of the best (and easier) ways to do this is to get a high profile stat counter.
look into BBClone (http://bbclone.de/). Simple set up, updated often and has more stats than you can remember. I used it very well for a very long time until my site grew so large and popular that it was starting to fall behind.
queerfm
02-16-2007, 07:00 AM
I this code has something wrong in it. I am looking for something that gives the user a drop down box they pick the langage that they want. after clicking go it takes them to http://www.YOURDOMAIN.com/en or http://www.YOURDOMAIN.com/ch
<?php
$homepage = 'http://'.$_SERVER["HTTP_HOST"].'/';
if ($_REQUEST['act'] == "setLang") {
//check to see if the form has been submitted!
if ($_REQUEST['lang'] == "") {
header('Location: '.$_SERVER["PHP_SELF"]);
//if language selection is empty, redirect to form!
}
else {
//if language was selected, save it in a cookie, then redirect to appropriate page!
$lang = $_REQUEST['lang'];
setcookie("language, $lang, time()+3600);
header('Location: '.$homepage.$lang);
}
}
else {
//if form has not been submitted
if (@$_COOKIE['language'] != "") {
/* check to see if language cookie is empty. If not, redirect to appropriate page. */
header('Location: '.$homepage.$_COOKIE["language"]);
}
else {
//if cookie is empty, display form
?>
<html>
<head>
<title>Language Cookie Test</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="act" value="setLang">
<select name="lang">
<option value="en">English</option>
<option value="sp">Spanish</option>
<option value="ru">Russian</option>
</select>
<input type="submit" value="Set Language">
</form>
</body>
</html>
<?php
}
}
?>
Also i need it to remember what the user choosed.
thetestingsite
02-16-2007, 03:28 PM
You say there is something wrong with the code, but you don't say what it is/isn't doing. By looking at the code, it should work fine; however, if you say it has a problem, let us know what it is.
chechu
02-20-2007, 02:13 PM
Hey,
Below you will find the cookie to remember the language choice.
But this one is using a form. How is the code, if I let people choose by just clicking a test link ? (see here (http://www.cecicasariego.com) ?
<?php
$homepage = 'http://'.$_SERVER["HTTP_HOST"].'/';
if ($_REQUEST['act'] == "setLang") {
//check to see if the form has been submitted!
if ($_REQUEST['lang'] == "") {
header('Location: '.$_SERVER["PHP_SELF"]);
//if language selection is empty, redirect to form!
}
else {
//if language was selected, save it in a cookie, then redirect to appropriate page!
$lang = $_REQUEST['lang'];
setcookie("language, $lang, time()+3600);
header('Location: '.$homepage.$lang);
}
}
else {
//if form has not been submitted
if (@$_COOKIE['language'] != "") {
/* check to see if language cookie is empty. If not, redirect to appropriate page. */
header('Location: '.$homepage.$_COOKIE["language"]);
}
else {
//if cookie is empty, display form
?>
<html>
<head>
<title>Language Cookie Test</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="act" value="setLang">
<select name="lang">
<option value="en">English</option>
<option value="sp">Spanish</option>
<option value="ru">Russian</option>
</select>
<input type="submit" value="Set Language">
</form>
</body>
</html>
<?php
}
}
?>
thetestingsite
02-21-2007, 03:35 PM
To save the cookie as a link, try the following.
<?php
$homepage = 'http://'.$_SERVER["HTTP_HOST"].'/';
if ($_REQUEST['act'] == "setLang") {
//check to see if the form has been submitted!
if ($_REQUEST['lang'] == "") {
header('Location: '.$_SERVER["PHP_SELF"]);
//if language selection is empty, redirect to form!
}
else {
//if language was selected, save it in a cookie, then redirect to appropriate page!
$lang = $_REQUEST['lang'];
setcookie("language, $lang, time()+3600);
header('Location: '.$homepage.$lang);
}
}
else {
//if form has not been submitted
if (@$_COOKIE['language'] != "") {
/* check to see if language cookie is empty. If not, redirect to appropriate page. */
header('Location: '.$homepage.$_COOKIE["language"]);
}
else {
//if cookie is empty, display form
?>
<html>
<head>
<title>Language Cookie Test</title>
</head>
<body>
<a href="?act=setLang&lang=en">English</a>
<a href="?act=setLang&lang=sp">Spanish</a>
<a href="?act=setLang&lang=ru">Russian</a>
</body>
</html>
<?php
}
}
?>
Hope this helps.
chechu
02-21-2007, 03:39 PM
Below is the code of my site.
Can that be implemented ?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Welcome to the official website of Ceci Casariego Mazereel</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="imagetoolbar" content="no">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.id {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8px;
color: #000000;
}
-->
</style>
</head>
<style>
a:hover{text-decoration:none}
</style>
<style type="text/css">
<!--
body
{
scrollbar-face-color:white;
scrollbar-arrow-color:white;
scrollbar-track-color:white;
scrollbar-shadow-color:white;
scrollbar-highlight-color:white;
scrollbar-3dlight-color:white;
scrollbar-darkshadow-Color:white;
background-attachment: fixed;
}
-->
</style>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<script language=JavaScript>
<!--
var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</script>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align="center" valign="middle">
<table width="500" border="0" cellpadding="0" cellspacing="0">
<tr><td height="410">
<table width="500" height="410" border="0" cellpadding="0" cellspacing="0" bgcolor=white>
<tr><td>
<div style="width:490px;height:400px;overflow:auto;">
<table width=90% height=100% align=center valign=middle>
<tr><td align=center valign=middle style="padding-top:10px; padding-bottom:10px;">
<img src="indexlogo.jpg" border="0">
<br>
<br>
<ilayer width=98% height=20 name="dep1">
<layer name="dep2" width=98% height=20>
</layer>
</ilayer>
<div id="describe" style="bgcolor:'white';width:200px;height:32px" onMouseover="clear_delayhide()" onMouseout="resetit(event)"></div>
<script language="JavaScript1.2">
var submenu=new Array()
submenu[0]='<font color="5A6673">Welcome to the official site of<br>Ceci Casariego-Mazereel</font>'
submenu[1]='<font color="5A6673">Bienvenu au site officiel de<br>Ceci Casariego-Mazereel</font>'
submenu[2]='<font color="5A6673">Welkom op de officiële site van<br>Ceci Casariego-Mazereel</font>'
var delay_hide=10
var menuobj=document.getElementById? document.getElementById("describe") : document.all? document.all.describe : document.layers? document.dep1.document.dep2 : ""
function showit(which){
clear_delayhide()
thecontent=(which==-1)? "" : submenu[which]
if (document.getElementById||document.all)
menuobj.innerHTML=thecontent
else if (document.layers){
menuobj.document.write(thecontent)
menuobj.document.close()
}
}
function resetit(e){
if (document.all&&!menuobj.contains(e.toElement))
delayhide=setTimeout("showit(-1)",delay_hide)
else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhide=setTimeout("showit(-1)",delay_hide)
}
function clear_delayhide(){
if (window.delayhide)
clearTimeout(delayhide)
}
function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}
</script>
<a href="EN/indexEN.html" onMouseover="showit(0)"><img src="NL/img/icon/vlagEN.gif" style="border:0"></a>
<a href="FR/indexFR.html" onMouseover="showit(1)"><img src="NL/img/icon/vlagFR.gif" style="border:0"></a>
<a href="NL/indexNL.html" onMouseover="showit(2)"><img src="EN/img/icon/vlagNL.gif" style="border:0"></a>
<p>
<font class="id">
all content and visuals copyright 2004-2007<br>
best viewed with IE 5+ in 1280*1024 </font>
</td></tr></table>
</div>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
thetestingsite
02-21-2007, 03:44 PM
<?php
$homepage = 'http://'.$_SERVER["HTTP_HOST"].'/';
if ($_REQUEST['act'] == "setLang") {
//check to see if the form has been submitted!
if ($_REQUEST['lang'] == "") {
header('Location: '.$_SERVER["PHP_SELF"]);
//if language selection is empty, redirect to form!
}
else {
//if language was selected, save it in a cookie, then redirect to appropriate page!
$lang = $_REQUEST['lang'];
setcookie("language, $lang, time()+3600);
header('Location: '.$homepage.$lang.'/index'.$lang.'.html');
}
}
else {
//if form has not been submitted
if (@$_COOKIE['language'] != "") {
/* check to see if language cookie is empty. If not, redirect to appropriate page. */
header('Location: '.$homepage.$_COOKIE["language"].'/index'.$_COOKIE["language"].'.html');
}
else {
//if cookie is empty, display form
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Welcome to the official website of Ceci Casariego Mazereel</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="imagetoolbar" content="no">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.id {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8px;
color: #000000;
}
-->
</style>
</head>
<style>
a:hover{text-decoration:none}
</style>
<style type="text/css">
<!--
body
{
scrollbar-face-color:white;
scrollbar-arrow-color:white;
scrollbar-track-color:white;
scrollbar-shadow-color:white;
scrollbar-highlight-color:white;
scrollbar-3dlight-color:white;
scrollbar-darkshadow-Color:white;
background-attachment: fixed;
}
-->
</style>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<script language=JavaScript>
<!--
var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</script>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align="center" valign="middle">
<table width="500" border="0" cellpadding="0" cellspacing="0">
<tr><td height="410">
<table width="500" height="410" border="0" cellpadding="0" cellspacing="0" bgcolor=white>
<tr><td>
<div style="width:490px;height:400px;overflow:auto;">
<table width=90% height=100% align=center valign=middle>
<tr><td align=center valign=middle style="padding-top:10px; padding-bottom:10px;">
<img src="indexlogo.jpg" border="0">
<br>
<br>
<ilayer width=98% height=20 name="dep1">
<layer name="dep2" width=98% height=20>
</layer>
</ilayer>
<div id="describe" style="bgcolor:'white';width:200px;height:32px" onMouseover="clear_delayhide()" onMouseout="resetit(event)"></div>
<script language="JavaScript1.2">
var submenu=new Array()
submenu[0]='<font color="5A6673">Welcome to the official site of<br>Ceci Casariego-Mazereel</font>'
submenu[1]='<font color="5A6673">Bienvenu au site officiel de<br>Ceci Casariego-Mazereel</font>'
submenu[2]='<font color="5A6673">Welkom op de officiële site van<br>Ceci Casariego-Mazereel</font>'
var delay_hide=10
var menuobj=document.getElementById? document.getElementById("describe") : document.all? document.all.describe : document.layers? document.dep1.document.dep2 : ""
function showit(which){
clear_delayhide()
thecontent=(which==-1)? "" : submenu[which]
if (document.getElementById||document.all)
menuobj.innerHTML=thecontent
else if (document.layers){
menuobj.document.write(thecontent)
menuobj.document.close()
}
}
function resetit(e){
if (document.all&&!menuobj.contains(e.toElement))
delayhide=setTimeout("showit(-1)",delay_hide)
else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhide=setTimeout("showit(-1)",delay_hide)
}
function clear_delayhide(){
if (window.delayhide)
clearTimeout(delayhide)
}
function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}
</script>
<a href="?act=setLang&lang=EN" onMouseover="showit(0)"><img src="NL/img/icon/vlagEN.gif" style="border:0"></a>
<a href="?act=setLang&lang=FR" onMouseover="showit(1)"><img src="NL/img/icon/vlagFR.gif" style="border:0"></a>
<a href="?act=setLang&lang=NL" onMouseover="showit(2)"><img src="EN/img/icon/vlagNL.gif" style="border:0"></a>
<p>
<font class="id">
all content and visuals copyright 2004-2007<br>
best viewed with IE 5+ in 1280*1024 </font>
</td></tr></table>
</div>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?php
}
}
?>
Try that, it should work, but let me know if it doesn't.
chechu
02-21-2007, 04:01 PM
Doesn't work.
See here: http://www.cecicasariego.com/indexcookie.php
thetestingsite
02-21-2007, 05:34 PM
Ok, found the problem and it is fixed now. Below is the code and you will see the one little thing that was causing it to show a blank page highlighted in red.
<?php
$homepage = 'http://'.$_SERVER["HTTP_HOST"].'/';
if ($_REQUEST['act'] == "setLang") {
//check to see if the form has been submitted!
if ($_REQUEST['lang'] == "") {
header('Location: '.$_SERVER["PHP_SELF"]);
//if language selection is empty, redirect to form!
}
else {
//if language was selected, save it in a cookie, then redirect to appropriate page!
$lang = $_REQUEST['lang'];
setcookie("language", $lang, time()+3600);
header('Location: '.$homepage.$lang.'/index'.$lang.'.html');
}
}
else {
//if form has not been submitted
if (@$_COOKIE['language'] != "") {
/* check to see if language cookie is empty. If not, redirect to appropriate page. */
header('Location: '.$homepage.$_COOKIE["language"].'/index'.$_COOKIE["language"].'.html');
}
else {
//if cookie is empty, display form
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Welcome to the official website of Ceci Casariego Mazereel</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="imagetoolbar" content="no">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.id {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8px;
color: #000000;
}
-->
</style>
</head>
<style>
a:hover{text-decoration:none}
</style>
<style type="text/css">
<!--
body
{
scrollbar-face-color:white;
scrollbar-arrow-color:white;
scrollbar-track-color:white;
scrollbar-shadow-color:white;
scrollbar-highlight-color:white;
scrollbar-3dlight-color:white;
scrollbar-darkshadow-Color:white;
background-attachment: fixed;
}
-->
</style>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<script language=JavaScript>
<!--
var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</script>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align="center" valign="middle">
<table width="500" border="0" cellpadding="0" cellspacing="0">
<tr><td height="410">
<table width="500" height="410" border="0" cellpadding="0" cellspacing="0" bgcolor=white>
<tr><td>
<div style="width:490px;height:400px;overflow:auto;">
<table width=90% height=100% align=center valign=middle>
<tr><td align=center valign=middle style="padding-top:10px; padding-bottom:10px;">
<img src="indexlogo.jpg" border="0">
<br>
<br>
<ilayer width=98% height=20 name="dep1">
<layer name="dep2" width=98% height=20>
</layer>
</ilayer>
<div id="describe" style="bgcolor:'white';width:200px;height:32px" onMouseover="clear_delayhide()" onMouseout="resetit(event)"></div>
<script language="JavaScript1.2">
var submenu=new Array()
submenu[0]='<font color="5A6673">Welcome to the official site of<br>Ceci Casariego-Mazereel</font>'
submenu[1]='<font color="5A6673">Bienvenu au site officiel de<br>Ceci Casariego-Mazereel</font>'
submenu[2]='<font color="5A6673">Welkom op de officiële site van<br>Ceci Casariego-Mazereel</font>'
var delay_hide=10
var menuobj=document.getElementById? document.getElementById("describe") : document.all? document.all.describe : document.layers? document.dep1.document.dep2 : ""
function showit(which){
clear_delayhide()
thecontent=(which==-1)? "" : submenu[which]
if (document.getElementById||document.all)
menuobj.innerHTML=thecontent
else if (document.layers){
menuobj.document.write(thecontent)
menuobj.document.close()
}
}
function resetit(e){
if (document.all&&!menuobj.contains(e.toElement))
delayhide=setTimeout("showit(-1)",delay_hide)
else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhide=setTimeout("showit(-1)",delay_hide)
}
function clear_delayhide(){
if (window.delayhide)
clearTimeout(delayhide)
}
function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}
</script>
<a href="?act=setLang&lang=EN" onMouseover="showit(0)"><img src="NL/img/icon/vlagEN.gif" style="border:0"></a>
<a href="?act=setLang&lang=FR" onMouseover="showit(1)"><img src="NL/img/icon/vlagFR.gif" style="border:0"></a>
<a href="?act=setLang&lang=NL" onMouseover="showit(2)"><img src="EN/img/icon/vlagNL.gif" style="border:0"></a>
<p>
<font class="id">
all content and visuals copyright 2004-2007<br>
best viewed with IE 5+ in 1280*1024 </font>
</td></tr></table>
</div>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?php
}
}
?>
That one quotation mark caused the whole script to error. Anyways, I tested it (to the extent that I could) and it works. The cookie gets set with the selection, then it redirects to the correct page. Also, when you revisit the page, it redirects you to the language you have chosen previously.
Hope this helps and let me know if you need any more help.
chechu
02-21-2007, 06:57 PM
Don't know why, but I still get a blank page.
When I copy the above code, it all shows up in one line.
Could that cause the error ?
chechu
09-27-2008, 08:00 AM
I have issues with this script.
This is the code I have now:
<?php
$homepage = 'http://'.$_SERVER["HTTP_HOST"].'/';
if ($_REQUEST['act'] == "setLang") {
//check to see if the form has been submitted!
if ($_REQUEST['lang'] == "") {
header('Location: '.$_SERVER["PHP_SELF"]);
//if language selection is empty, redirect to form!
}
else {
//if language was selected, save it in a cookie, then redirect to appropriate page!
$lang = $_REQUEST['lang'];
setcookie("language", $lang, time()+3600);
header('Location: '.$homepage.$lang.'/index'.$lang.'.php');
}
}
else {
//if form has not been submitted
if (@$_COOKIE['language'] != "") {
/* check to see if language cookie is empty. If not, redirect to appropriate page. */
header('Location: '.$homepage.$_COOKIE["language"].'/index'.$_COOKIE["language"].'.php');
}
else {
//if cookie is empty, display form
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<head>
<title>Ceci Casariego: portretten, portret, interieur decoratie, ontwerp en creaties</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" media="all" type="text/css" href="site.css">
<meta http-equiv="imagetoolbar" content="no">
<script src="links.js" type="text/javascript"></script>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
</head>
<body>
<div id="header-main">
<div id="header">
<h1>Ceci CASARIEGO</h1>
<ul>
<li class="nav"><a href="?act=setLang&lang=NL">Nederlands</a></li>
<li class="nav"><a href="?act=setLang&lang=EN">English</a></li>
<li class="nav"><a href="?act=setLang&lang=FR">Français</a></li>
</ul>
</div>
</div>
<div id="body-main">
<div id="body">
<div id="left">
</div>
<div id="right">
</div>
</div>
</div>
</body>
</html>
<?php
}
}
?>
I highlighted the added php. The href I need the links to go to are indexNL.php, indexGB.php and indexFR.php , but they don't direct to these pages. What needs to be changed, please ?
chechu
09-29-2008, 11:41 AM
Anyone, please ?
mukkie
10-02-2008, 06:49 AM
It indeed looks strange that the href where your site should be going to, does not include the names of the pages. But I am no expert !
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.