View Single Post
Old May 29th, 2007, 4:30 PM   #3
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,005
Rep Power: 5 lectricpharaoh will become famous soon enough
I've never used PHP, but I have an idea you can try. In C, you have the tmpfile() and tmpnam() functions; these create a temporary file in the current directory and a unique name for a temporary file. I'm assuming that PHP may well have something similar. You can then have both users create a file (each file will have its own unique name), and when one submits, it tries to rename the file as xxx.php, with xxx being your incrementing value. One of these rename attempts (ie, the first) should work; the other will not, and will raise an error/exception/whatever. If you detect this error condition, increment and attempt the rename again.

Given that this situation should only arise when two people try to save the form at the same moment, it shouldn't be a very frequent occurrence.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote