Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,457
    Thanks
    15
    Thanked 0 Times in 0 Posts

    lock a record from editing

    i have a form in an admin program i wrote that more then one people can be logged in and editing at the same time.
    is it possible to make the form that it can detect if someone else has the saem form open and if so make it read only.

  • #2
    New Coder
    Join Date
    Nov 2006
    Location
    UK
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could do this by having a mySQL table called 'template_locked' and then set that table to the id of the person editing it, and then when the form is submitted/tried to edit it then have the script test this field and compare it against the user id.if it matches allow it to continue, if not exit we cant edit template.
    - Mark

  • #3
    Senior Coder
    Join Date
    May 2004
    Posts
    1,457
    Thanks
    15
    Thanked 0 Times in 0 Posts
    but how do I know they are editing?
    it's just an html form that pulls the data from the db

  • #4
    New Coder
    Join Date
    Nov 2006
    Location
    UK
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    when the users clicks "edit" make the script query the database setting the template clicked to locked with there user id.
    - Mark

  • #5
    Senior Coder
    Join Date
    May 2004
    Posts
    1,457
    Thanks
    15
    Thanked 0 Times in 0 Posts
    but then if the session times out or they don't click save but just close the window then the record will be on edit forever wont' it?

  • #6
    Regular Coder anarchy3200's Avatar
    Join Date
    Mar 2003
    Location
    England
    Posts
    261
    Thanks
    0
    Thanked 1 Time in 1 Post
    Well create an extra field when you set the id that locked it and put in that the time it was checked out at, then you check the id and the checkout time.
    If no id set : can edit
    If id set: check time
    ---
    If time > 15mins ago : can edit
    If time < 15mins ago : cannot edit
    Mike

  • #7
    Senior Coder
    Join Date
    May 2004
    Posts
    1,457
    Thanks
    15
    Thanked 0 Times in 0 Posts
    is there anyway to clear it on timeout or when the browser is closed?

    it's just that someone can be on the form for more then 15 mintues so that's not really the best way.

  • #8
    Regular Coder anarchy3200's Avatar
    Join Date
    Mar 2003
    Location
    England
    Posts
    261
    Thanks
    0
    Thanked 1 Time in 1 Post
    Well the timestamp could only be updated on a submission by the user, i.e. them submitting the form, if the data entry takes longer then i think you would just have to use a longer time and accept the inconvenience of having to wait for it.
    For your example of on the browser being closed at this point no information is sent to the server so it wouldn't be posible to remove the lock at this point.
    Mike


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •