Text files are good providing the vote is simple.
I would recommend using file locking, but to stop a user recieving an error
if the file is in use you could get the script to retry after half a second
or so.
A good structure would be to have one file for each possible answer and each
file contains the number of votes it has recieved.
Then:
--> Open file for the chosen option as read only
--> Read the value in the file
--> Close the file
--> Increase the value by one using ++
--> Open the file again in write mode
--> Lock the file
--> Write the new value to the file - old one overwritten
--> Unlock the file
--> Close the file

I don't do the file locking bit and I've never had problems but my script
doesn't get heavy useage!
You'll have to make sure all your files are CHMODed properly to allow them
to be open and written to etc. I had a problem where my host did something
to the system, changed the privelages and as a result my guestbook got wiped
because it couldn't replace a file!



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to