I don't understand that, but anyway... You're going to be dependent on the database however you do it. I think the database would be the easiest route (for the server), but the second-easiest would be a modified filename. The filename will depend on the user's ID which will come from the DB.
Code:
<?php
$id = // the user's ID
$file = $id . '.txt';
if(!file_exists($file)){
file_put_contents($file, '0');
}
if($_GET['click'] == 'yes'){
file_put_contents($file, ((int) file_get_contents($file)) + 1);
header('Location: ' . $_SERVER['SCRIPT_NAME']);
die;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>counter example</title>
</head>
<body>
<h1><?php echo file_get_contents($file); ?></h1>
<a href="?click=yes">clickMe</a>
</body>
</html>
Bookmarks