in order to edit the file on the server you need to run a servlet b/c normal users simply wont have right access to the driectory in question.....in order to run a servlet the server needs to kno what to do with class files, or at the very least have j2re installed...if normal clients had the access necessary to open a file on the server, write to said file on server, and then proceed to close said file on server i wouldnt have much control over what was on my site, now would i? you can HTTP POST the variable up to the server but you need a servlet or other script in order to tell the server what to do w/ the variable...if you could have the counter query a mySQL database i could set up an account on the db server that you could use for that which is much simpler than setting up the server to run servlets...and using a client side script to write to server side files simply isnt efficient in the first place...
Code: Select all
<?php
$counter_file = "icancount.dat";
if(!($fp = fopen($counter_file , "r"))) die ("file no go open. hah.");
$counter = (int)fread($fp, 24);
fclose($fp);
$counter++;
$fp = fopen($counter_file , "w");
fwrite($fp, $counter);
fclose($fp);
?>
<?php
for ($i = 0 ;$i < strlen($counter) ; $i++)
{
$imgsrc = SubStr($counter,$i ,1);
echo "<img src =\"images/" . $imgsrc . ".GIF\" width=\"30\" height=\"40\">";
}
?>
this server passes htm, html and php documents thro the php processor so if u put that code in an html file and have the file "icancount.dat" in the same directory it will embed pictures 0-9 from the images/ directory....it can do the counting b/c PHP is a server side script...btw this is the code for the counter in use on the main page.[/code]