Forum Moderators: coopster
How do you want to store the data? I see two options, in a file or in a db. I would think if you are just storing the number you should probably use a file.
The button would have a form action of itself, I would think, unless you want it to go somewhere else after they click. When they click you read the integer out of the file, add 1 and write the new number to the file (as well as displaying it probably).
I am going to give some php functions you may need since you didn't specify which language you have available.
You can fire it when they click the button by using a hidden field in the form.
Substitute "pagename.php" with the actual page name in the form below.
the form
<form action="pagename.php" method="post">
<input type="submit" value="add to counter">
<input type="hidden" name="action" value="add">
</form>
little update script
<?
if (isset($action) && $action == "add") {
$fp = fopen('counter.txt','r+');
$lastcount = fread($fp,1024);
$lastcount += 1;
rewind($fp);
fwrite($fp,$lascount);
fclose($fp);
echo "added 1 to counter";
}
?>
think that's right, it is just off the top of my head. Most of the functions can be found here
Filesystem Functions [ca.php.net]
The file counter.txt would need to be in the same folder as this page and would contain nothing but a number. I would suggest 1 to start. ;) The file would also have to be writable so "chmod 777".
The page would have to have a php extension and you would have to have php available on your server.
Any one can correct me or make a shorter/better one if they like. This is just a "push in the right direction".