My code is working fine, but there is a simple cookie modification I want to make. The problem I am facing is that if someone goes to another page and then comes back to the home page, the page rotates again which defeats the object of this code. (Code is for rotating webpages).
Therefore, I believe I need to add the following cookie script:
At beginning of code:
If cookie exists, then open index . cookievalue.htm and then exit php code
else
setcookie before updating count.inc
My half completed code is below with the sections I am stuck on being highlighted:
<?php
//Simple PHP headline swapper
////////////////////Stuck on this area///////
if $ICCTestCode exists then {
$filename = 'index'.$ICCTestCode.'.htm';
include("$filename");
end php code}
else continue with code
/////////////////////////////////////////////////
if (file_exists('count.inc'))
{
//if file exists..read the last supplied file.
$fil = fopen('count.inc', 'r');
$dat = fread($fil, filesize('count.inc'));
fclose($fil);
}
else
{
//if it doesnt exist. create one.
// in ur code , if file doesnt exist, it wont display any headers. i have corrected it here.
$fil = fopen('count.inc', 'w');
fwrite($fil, 0);
fclose($fil);
$dat = 0;
}
//using include to display the appropriate page:
/////////////////add code here?//////////////////
setcookie ("ICCTestCode", $dat,time()+259200);
////////////////////////////////////////////////////////
$filename = 'index'.$dat.'.htm';
include("$filename");
// my approach for rewinding value of dat..
if($dat > 0) {
$dat = 0;
}
else
{
$dat++;
}
//now write in the new value...
$fil = fopen('count.inc', 'w');
fwrite($fil, $dat);
fclose($fil);
?>
[code=php]
I have highlighted my modifications using "/////////////////////////".
My php isn't too hot and my psuedo code obviously won't work.
Anyone help?
Thanks,
Jon