Hello people, OK, so this is what it's all about - i need to create a script that will delay a few functions. but... i need it to work with a few things together and this is where i get confused.. anyway - my website needs to work like this: 1) user on my site clicks submit -> data sent to 3rd part website and also saved on DB. 2) the 3rd part website sends back some other data back to my site. 3) the system using this data to get the right information from DB and.. well.. this is were i am stuck. basically - i need the data to be send once again to another 3rd part website with a delay. but, the delay should be unique for the user request.. i know that i can use this to make delay: <?php $data = $_POST['data']; //get the data that sent back. sleep(60); //set delay for 1 min //run the script that will run after 60 seconds. //rest of the script... ?> what i need to do is that the script will be able to work if the 3rd part website send some data 2(or more) times while the delay is set. for example - user1 click submit now and delay set for 5 minutes, but user2 clicks submit 1 minute after user1 and delay for him should be 1 minute.. how to make it done right.. ? use sessions? write a file per unique request? please give me some advice on how to make a unique time php timer script. i hope i am clear with all this mixup.. thanks!
Your issue is unclear, but it sounds like you need to structure some type of "queuing" logic. You could perform the delay using a cron job that is either running all the time or is setup/torndown "on the fly."
You need to have a value to understand which step is running. Let say, when you make the first post put a value named example : step=1; so you coud try something like this : if (isset($_POST['data'])) { if (isset($_POST['step']) && ($_POST['step']==1)) { ob_flush(); flush(); # first time post functions where step is posted from your form usleep(100000); } else { ob_flush(); flush(); # second time post functions usleep(100000); } } else { #run the rest of your code or functions } PHP: change usleep to whatever your timing is. Just an idea !