faure,
What degree of granularity are you trying to achieve?
- Page level, individual field changes are not tracked.
- Field level - changes are tracked when a value change is complete.
- Keystroke level - field change details are tracked as the user them
For
#1, you can simply database each page's changes when the user transmits the page. Not only are values stored, but the name of the last form displayed, as well. To recover, simply post the "last form" with the most recent values that are stored in the database.
For
#2, you will want to use jQuery (or bare JavaScript) to make an AJAX connection to a REST service that you use to track each field change. The data you send are 1) the name of the changed field, 2) the new value, 3) the field that the user just entered, and 4) the form that the user just entered. Recovery is similar to
#1, however you need to dynamically create a bit of JavaScript that sets the focus (cursor position) correctly.
For
#3, you do everything as in
#2, but you have to track on each detail change and the cursor position (for instance, the user is editing in the middle of a text box). Likewise, recovery is nearly identical, however you need to position the cursor down to the character level, on a specific check-box, or wherever.
As a first cut, I would recommend that you implement
#1, as it requires no additional JavaScript or construction of a REST interface. This solution can be completely contained within your PHP, which makes maintenence straightforward for anyone helping you. The complexity will come in that each PHP page will now have (potentially) complex data-storage and recovery blocks of code.
IMHO, level
#2, field level tracking, is the most elegant solution from an end-customer (user) perspective. You have to implement change tracking on
all fields, but this is relatively straightforward using jQuery. Elegance comes at a cost, however - you will have to craft the REST interface for change tracking. Also, your PHP code will have to have recovery blocks inserted, as in
#1.
IMO, Level
#3 is more of academic interest than a practical methodology - simply because most users are not going to be able to recover their train of thought at the middle of a value change. The only time that I might consider this level of change tracking is if you had a web site like ours (
Bytes), where people spend significant amounts of time writing original work. Even then, I would suggest using a temporal (time-based) tracking strategy, rather than tracking keystrokes.
Good Luck!
Oralloy