Click to See Complete Forum and Search --> : PHP & SQL Advice!


wick3dsunny
09-08-2008, 06:35 PM
Hi Guys,

I wanted a possible solution from you guys... I have a online locker system functional which allocates random locker id's to people and takes them to the paypal page for payment and then sends an email about locker info on payment success.

Now, the problem is, if two people at the same time, select that they want a random locker, both of them get same locker and both of them pay, but at the success screen, one gets the locker info and other gets a error msg saying locker no already sold....

Is there any way to block the locker for a timespan temporarily?

Yelgnidroc
09-08-2008, 07:01 PM
Would something like this help:

When a locker is selected, update your database, set a `lock_expiry_time` 5 minutes (or however long you want) in the future, and also a `lock_key` equivalent to the php session_id().

If someone tries to select the same locker, only allow them to have it if the `lock_expiry_time` has passed - also set a `lock_key` equivalent to the php session_id().

If someone has the `lock_key` and the `lock_expiry_time` has NOT passed then take payment.

Hope you get the gist of it, and you can play around to suit your requirements.

wick3dsunny
09-08-2008, 07:17 PM
how do i set a time limit to the reserved locker ?


Something like make a temp variable like time() + 36000 and save it in the database? How would it get deleted from the database after 36000 ?

Yelgnidroc
09-09-2008, 05:30 AM
MySQL - UPDATE database SET lock_expiry_time = ADDTIME(NOW(),'00:05:00')