Forum Moderators: coopster
I a am making a small 2 page website.
My first page "product1.php" includes the following code:
---other head information are here--
<body>
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<?php
echo "Today's date: ". date("G:i - m/d/y");
?>
<img src="images/Header.gif" />
</td>
</tr>
<tr>
<td><img src="images/Navbar.gif" /></td>
</tr>
<tr>
<td bgcolor="#000000"><h2 class="style2">Dell XPS</h2></td>
</tr>
</table>
</body>
</html>
Now I would like to see if the user has visited the site before, using cookies.
I am thinking of doing something like
if(isset($_COOKIE['lastVisit']))
$visit = $_COOKIE['lastVisit'];
if(isset($_COOKIE['VisitedPage']))
$visit = $_COOKIE['VisitedPage'];
echo "Your last visit was - ". $visit;
Now this is where my understanding of PHP lacks. Where would I put that code does it make sense to put it after the date? is my cookie code correct? If any one has any websites that can help me with this it would be greatly apreciated.
I would also like to output when the sale will end or show the number of the days until the sale ends. I assume I would do this with the DATE fuction but I am having trouble understanding how to do this. Again if anyone has any websites that will help me understand this better....please let me know!
Thank you!
<html>
<head>
<script language="JavaScript">
function StartCountDown(myDiv,myTargetDate){
var dthen = new Date(myTargetDate);
var dnow = new Date();
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(myDiv,gsecs);
}function Calcage(secs, num1, num2){
s = ((Math.floor(secs/num1))%num2).toString();
if (s.length < 2){
s = "0" + s;
}
return (s);
}
function CountBack(myDiv, secs){
var DisplayStr;
var DisplayFormat = "%%D%% Days %%H%%:%%M%%:%%S%%";
DisplayStr = DisplayFormat.replace(/%%D%%/g,Calcage(secs,86400,100000));
DisplayStr = DisplayStr.replace(/%%H%%/g, Calcage(secs,3600,24));
DisplayStr = DisplayStr.replace(/%%M%%/g, Calcage(secs,60,60));
DisplayStr = DisplayStr.replace(/%%S%%/g, Calcage(secs,1,60));//if the time has not expired
if(secs > 0){
document.getElementById(myDiv).innerHTML = DisplayStr;
setTimeout("CountBack('" + myDiv + "'," + (secs-1) + ");", 1000);
}
//time has expired
else{
document.getElementById(myDiv).innerHTML = "Countdown has ended.";
}
}
</script>
</head>
<body>
<div id="clock1"></div><script language="JavaScript">
//initiates countdown
StartCountDown("clock1","06/18/2009 09:50 AM -0400");
</script>
</body>
</html>
So all you need to do is change the date in the line and you should be good to go.
StartCountDown("clock1","06/18/2009 09:50 AM -0400");