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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts

    Question Concept of Holding a reservation.

    Hi

    I was wondering how do you implement the concept of holding a registration of an event or a booking?

    For instance, when you try to book a hotel room or a try to book a air ticket online, they hold your registration for say 10 or 15 mins, during which the room or seat will be locked for that time and once the time expires, they release the holding.

    A real life example would be events hosting on eventbrite

    Code:
    http://collaboratemumbai-ehometext.eventbrite.com/
    How do we implement the same concept in an PHP application?



    Any help will be greatful.


    Thanks

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,692
    Thanks
    25
    Thanked 657 Times in 656 Posts
    I really don't think php can keep track of time, so if this becomes a php script you would need to start something else to do a count down for you.

    To do this easier I suggest you use javascript (Ajax). I can remove or halt an html entry from being clicked on for an amount of time; it then can add the entry back onto the page if the time elapses or process the purchase all without resending the page.

  • Users who have thanked sunfighter for this post:

    phantom007 (05-27-2011)

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    When the client goes to book it, put their sessionID and the time() into the database for that room. For any new clients trying to book it the script must check that the phpsession matches theirs and that the timestamp is from within the last 15 minutes.

    Job done.
    I can't really think of anything to write here now...

  • Users who have thanked tangoforce for this post:

    phantom007 (05-27-2011)

  • #4
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts
    Thanks for your reply.

    I will try it and shall come back to you if I have further doubt.


    THanks once again

  • #5
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts
    Hi Again

    I have implemented the concept and it works like a charm except for one case. Our QA team has discovered an issue and I am not sure if this is the problem of the code or the database queue request.

    Our QA team are testing this by clicking on the "Check Room Availability" button simultaneously on 2 different computers at a single point of time. 2 out of 20 times they succeed in breaking the rule.

    For example, for 10th July 2011 only 1 room is available in a hotel. If we proceed with booking this room for the aforesaid date, the application holds the reservation for 15 mins for that user. But if the "Check Room Availability" button is clicked by 2 users at the same point of time, the rule fails 2 times out of 20 attempts.

    What do you think the cause of this and how can we prevent it?

    Any suggestion will be highly appreciated.


    Many thanks in advance.

  • #6
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts

    Question

    HI Again

    I have an interesting question regarding the concept of holding a reservation.

    Suppose a registration is being held for a user for 20 mins, he fills up all the required forms (lets assume he spends 15 mins filling up the forms), after that the application takes him to the payment gateway page, where he spends 6-7 mins filling up teh credit card details, name etc.

    In the meanwhile a CRON which is set to run every 20 mins, deletes the record of that user from the database since the user has spent more than 20 mins for completing the whole process.

    After making a successful payment, when the user is redirected back to the application, the application does not find the matching record and displays an error to him saying your session has timed out etc.

    How would you handle or make the application handle such a case where the user has already made the payment?

    Any help / ideas will be highly appreciated.
    Last edited by phantom007; 06-27-2012 at 03:24 PM.


  •  

    Posting Permissions

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