|
发表于 2005-5-22 10:23:18
|
显示全部楼层
这里有一个计数器的实例,忘了在哪沾的,你试试:
[php]
<?php
//setcookie("kookie",$pagecount);
$pagecount=0;
if (!(isset($_COOKIE["kookie"])))
{setcookie("kookie",++$pagecount);
echo "<center> This is the first time you have accessed this page in this sesion.</center>";
echo "<center> A cookie was sent to you and stored in your computer.</center>";
}else{
$pagecount = ++$_COOKIE["kookie"];
setcookie("kookie",$pagecount,time()-10);
setcookie("kookie",$pagecount);
echo "<center> View Count : <b> ".$_COOKIE["kookie"]."</b></center>\n<br>";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="<?php echo $SCRIPT_NAME ?>" method="post" name="test">
<center> <input name="Submit" type="submit" value="refresh" ">
<b> Refresh button will refresh the page and the page count! :-)</b></center>
</form>
</body>
</html>
[/php] |
|