|
Posted by Frits van Leeuwen on 09/21/06 10:52
>>>> I start index.php. There I click at a link. Then I start a file.
>>>> With starting that file, I start a line for setting a cookie. After
>>>> it, I
>>>> like to go back (without a click) to index.php.
>>>> So the cookie is set. but then...
>>> Or alternatively in one file:
>>>
>>> index.php
>>> <?php
>>> if(isset($_REQUEST['cookie'])){
>>> setcookie(//etc);
>>> }
>>> //rest of index.php
>>> ?>
>>> <a href="./index.php?cookie">Set a cookie</a>
>>> or:
>>> <form method="post" action="./index.php">
>>> <input type="submit" name="cookie" value="Set a cookie">
>>> </form>
>> Thanks Rik,
>> Can you explane the last example?
>>
>
> In the last example, the index.php itself will set a cookie if the GET or
> POST array contains the named variable 'cookie'. No oher/intermediate
> files
> required.
>
That's intresting. But I'm not so in to php. So need some help. Can you tell
me how to change it in one file?
I have now 3 files: index.php, taal_en.php and taal_nl.php. Taal_en and
taal_nl are simular as eachother.
This is taal_en.php:
<?php
setcookie("LeeuwendeelTaal", "en", time()+3600*24); // 1 dag
echo "The language is English.";
header('Location: http://www.Leeuwendeel.info/index.php');
exit;
?>
This is index.php:
<?php
setcookie("LeeuwendeelTaal");
if (isset($_COOKIE["LeeuwendeelTaal"]))
{ // bestaat cookie? Ja
switch ($_COOKIE["LeeuwendeelTaal"]) // hier een case om NL of EN te kiezen
{
case "nl": // Nederlands
setcookie("LeeuwendeelTaal", "nl", time()+3600*24); // 1 dag
break 1;
case "en": // Engels
setcookie("LeeuwendeelTaal", "en", time()+3600*24); // 1 dag
break 1;
default: // keuze nog maken (of na F5)
break 1;
{
setcookie("LeeuwendeelTaal");
}
}
} // einde bestaat cookie? Ja
else
{ // bestaat cookie? Nee
} // einde bestaat cookie? Nee
?>
<html>
<head>
<meta http-equiv="Content-Language" content="nl">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Begin Leeuwendeel.info</title>
<bgsound src="geluiden/lion.wav" loop="0">
<meta name="keywords" content="Leeuwendeel familiewebsite van Leeuwen">
<meta name="description" content="Dit is de beginpagina van
www.Leeuwendeel.info">
<meta http-equiv="Site-Enter"
content="revealTrans(Duration=10.0,Transition=2)">
<meta http-equiv="Site-Exit"
content="revealTrans(Duration=5.0,Transition=3)">
<meta name="Microsoft Border" content="none">
</head>
<body link="#0000FF" vlink="#800080" alink="#00FFFF" text="#FF0000"
bgcolor="#FFFFE1">
<div align="center">
<table border="1" width="100%" id="table1" style="border-width: 0px"
height="530">
<?php
if (isset($_COOKIE["LeeuwendeelTaal"]))
{ // Nog eens: bestaat cookie? Ja
switch ($_COOKIE["LeeuwendeelTaal"])
{
case "nl": // Nederlands
?>
<tr>
<td style="border-style: none; border-width: medium">
<p align="center"><font size="4" face="Monotype Corsiva">
Welkom op de familie-website</font><br><font face="Monotype Corsiva"
size="5">"Leeuwendeel.info"</font><font size="4" face="Monotype
Corsiva">.<br>Zoals u ziet, zijn we hard aan het werk, om deze website in de
lucht te krijgen.</font></p>
</td>
<td rowspan="1" style="border-style: none; border-width: medium">
<p align="center"><img border="0" src="images/underconstruction.gif"
width="480" height="379"></p>
</td>
<td style="border-style: none; border-width: medium">
<!--vlag NL-->
<p align="right"><a href="taal_nl.php"><img border="1"
src="knoppen/vlagNL.jpg" width="33" height="20" alt="Klik hier, wanneer u de
site in het Nederlands wilt lezen."></a>
<!--vlag EN-->
<a href="taal_en.php"><img border="0" src="knoppen/vlagEN.jpg"
width="33" height="20" alt="Klik hier, wanneer u de site in het Nederlands
wilt lezen."></a>
</td>
</tr>
<?php
break 1; // Breek uit de switch
case "en": // Engels
?>
<tr>
<td style="border-style: none; border-width: medium">
<p align="center"><span lang="en-gb"><font size="4" face="Monotype
Corsiva">
Welcome at the family-website<br></font><font face="Monotype Corsiva"
size="5">"Leeuwendeel.info"</font><font size="4" face="Monotype
Corsiva">.<br>As you can see, we are very busy, to bring this website
online.</font></span></p>
</td>
<td rowspan="1" style="border-style: none; border-width: medium">
<p align="center"><img border="0" src="images/underconstruction.gif"
width="480" height="379"></p>
</td>
<td style="border-style: none; border-width: medium">
<!--vlag NL-->
<p align="right"><a href="taal_nl.php"><img border="0"
src="knoppen/vlagNL.jpg" width="33" height="20" alt="Klik hier, wanneer u de
site in het Nederlands wilt lezen."></a>
<!--vlag EN-->
<a href="taal_en.php"><img border="1" src="knoppen/vlagEN.jpg"
width="33" height="20" alt="Klik hier, wanneer u de site in het Nederlands
wilt lezen."></a>
</td>
</tr>
<?php
break 1; // Breek uit de switch
default: // geen taalkeuze (F5)
?>
<tr>
<td style="border-style: none; border-width: medium">
<p align="center"><font size="4" face="Monotype Corsiva">
Welkom op de familie-website</font><br><font face="Monotype Corsiva"
size="5">"Leeuwendeel.info"</font><font size="4" face="Monotype
Corsiva">.<br>Zoals u ziet, zijn we hard aan het werk, om deze website in de
lucht te krijgen.</font></p>
</td>
<td rowspan="1" style="border-style: none; border-width: medium">
<p align="center"><img border="0" src="images/underconstruction.gif"
width="480" height="379"></p>
</td>
<td style="border-style: none; border-width: medium">
<p align="center"><span lang="en-gb"><font size="4" face="Monotype
Corsiva">
Welcome at the family-website<br></font><font face="Monotype Corsiva"
size="5">"Leeuwendeel.info"</font><font size="4" face="Monotype
Corsiva">.<br>As you can see, we are very busy, to bring this website
online.</font></span></p>
</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium">
<p align="center"><a href="taal_nl.php"><img border="0"
src="knoppen/vlagNL.jpg" width="165" height="100" alt="Klik hier, wanneer u
de site in het Nederlands wilt lezen."></a>
</td>
<td style="border-style: none; border-width: medium">
</td>
<td style="border-style: none; border-width: medium">
<p align="center"><a href="taal_en.php"><img border="0"
src="knoppen/vlagEN.jpg" width="165" height="100" alt="Click here, when you
like to read the website in English."></a>
</td>
</tr>
<?php
break 1; // Breek uit de switch
}
}
else // Nog eens: bestaat cookie? Nee
{ // hier een handmatige keuze maken
?>
<tr>
<td style="border-style: none; border-width: medium">
<p align="center"><font size="4" face="Monotype Corsiva">
Welkom op de familie-website</font><br><font face="Monotype Corsiva"
size="5">"Leeuwendeel.info"</font><font size="4" face="Monotype
Corsiva">.<br>Zoals u ziet, zijn we hard aan het werk, om deze website in de
lucht te krijgen.</font></p>
</td>
<td rowspan="1" style="border-style: none; border-width: medium">
<p align="center"><img border="0" src="images/underconstruction.gif"
width="480" height="379"></p>
</td>
<td style="border-style: none; border-width: medium"><p
align="center"><span lang="en-gb">
<font size="4" face="Monotype Corsiva">
Welcome at the family-website<br></font><font face="Monotype Corsiva"
size="5">"Leeuwendeel.info"</font><font size="4" face="Monotype
Corsiva">.<br>As you can see, we are very busy, to bring this website
online.</font></span></p>
</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium">
<p align="center"><a href="taal_nl.php"><img border="0"
src="knoppen/vlagNL.jpg" width="165" height="100" alt="Klik hier, wanneer u
de site in het Nederlands wilt lezen."></a></p>
</td>
<td style="border-style: none; border-width: medium">
<p align="center"></p>
</td>
<td style="border-style: none; border-width: medium">
<p align="center"><a href="taal_en.php"><img border="0"
src="knoppen/vlagEN.jpg" width="165" height="100" alt="Click here, when you
like to read the website in English."></a></p>
</td>
</tr>
<?php
} // einde Nog eens: bestaat cookie? Ja/Nee
?>
</table>
</div>
<p align="center"><font size="1">Laatste wijziging:
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d-%m-%Y"
startspan -->10-09-2006<!--webbot bot="Timestamp" i-checksum="12558"
endspan --></font></p>
</body>
</html>
--------------------------------------------------------------------------------
Mijn Postvak In wordt beschermd door SPAMfighter
4017 spam-mails zijn er tot op heden geblokkeerd.
Download de gratis SPAMfighter vandaag nog!
Navigation:
[Reply to this message]
|