Panta Posted April 10, 2017 Share Posted April 10, 2017 I want to execute a script at a particular time. What i want is that i want a user after registration will wait for like 15 mins to be assigned to be paired with ob_start(); date_default_timezone_set('Africa/Lagos'); $exp_to_donate='1'; $exp_tobe_paid='2'; $paidto_redonate='3'; $redonated_exp_balance='4'; $balanced_exp_tobe_paid='5'; $mergestatus="no"; $awaiting='awaiting'; //adding time db just to get time $profvso = $flash->prepare("SELECT xtime FROM `merge` WHERE `sender`=:email"); $profvso->bindParam(':email',$_SESSION['login_user']); $profvso->execute(); $profjj = $profvso->fetch(); $currentPage = $_SERVER['PHP_SELF']; $currentTimestamp = strtotime(date('Y-m-d H:i:s')); //Define your startTime here in {Year-Month-Day Hour:Minute:Second} format $startTime = $profjj['xtime']; $startTimestamp = strtotime($startTime); $numOfSecondsToReload = $startTimestamp - $currentTimestamp; if($startTimestamp >= $currentTimestamp) { ?> <!--<p>Live at <?php //echo date('H:i', $startTimestamp); ?></p>--> <?php //assigning sponsor to user //check if anyone is qualifies to receive $place = $flash->prepare("SELECT * FROM `user` WHERE ((`level`=:exp_tobe_paid) OR (`level`=:redonated_exp_balance) OR (`level`=:balanced_exp_tobe_paid)) AND `merged`=:no LIMIT 1"); $place->bindParam(':exp_tobe_paid',$exp_tobe_paid); $place->bindParam(':redonated_exp_balance',$redonated_exp_balance); $place->bindParam(':balanced_exp_tobe_paid',$balanced_exp_tobe_paid); $place->bindParam(':no',$mergestatus); $place->execute(); if($place->rowCount() > 0) { $profin = $place->fetch(); $togethelp=$profin['email'];//sponsor email $payment_time= date("Y-m-d H:i:s",strtotime(date("Y-m-d H:i:s")." +3 hours"));//adding 3hrs to the current time if($merged!=="yes"){ $gonow = $flash->prepare("UPDATE `merge` SET `receiver`=:togethelp,`payment_time`=:payment_time WHERE `sender`=:email"); $gonow->bindParam(':email',$email); $gonow->bindParam(':togethelp',$togethelp); $gonow->bindParam(':payment_time',$payment_time); if($gonow->execute()){ $up= $flash->query("UPDATE `user` SET merged='yes' WHERE `email`='$email'"); $up2= $flash->query("UPDATE `user` SET merged='yes' WHERE `email`='$togethelp'"); } }//end of if there is someone to pay header( "refresh:$numOfSecondsToReload;$currentPage"); }//end of if the time is greater } //end of assign sponsor to user ?> . but the script i have doesnt allow them stay till 15mins. if you refresh the page twice it will assign someone to them which is not what i want. This is my script Link to comment Share on other sites More sharing options...
Panta Posted April 10, 2017 Author Share Posted April 10, 2017 14 minutes ago, Panta said: I want to execute a script at a particular time. What i want is that i want a user after registration will wait for like 15 mins to be assigned to be paired with ob_start(); date_default_timezone_set('Africa/Lagos'); $exp_to_donate='1'; $exp_tobe_paid='2'; $paidto_redonate='3'; $redonated_exp_balance='4'; $balanced_exp_tobe_paid='5'; $mergestatus="no"; $awaiting='awaiting'; //adding time db just to get time $profvso = $flash->prepare("SELECT xtime FROM `merge` WHERE `sender`=:email"); $profvso->bindParam(':email',$_SESSION['login_user']); $profvso->execute(); $profjj = $profvso->fetch(); $currentPage = $_SERVER['PHP_SELF']; $currentTimestamp = strtotime(date('Y-m-d H:i:s')); //Define your startTime here in {Year-Month-Day Hour:Minute:Second} format $startTime = $profjj['xtime']; $startTimestamp = strtotime($startTime); $numOfSecondsToReload = $startTimestamp - $currentTimestamp; if($startTimestamp >= $currentTimestamp) { ?> <!--<p>Live at <?php //echo date('H:i', $startTimestamp); ?></p>--> <?php //assigning sponsor to user //check if anyone is qualifies to receive $place = $flash->prepare("SELECT * FROM `user` WHERE ((`level`=:exp_tobe_paid) OR (`level`=:redonated_exp_balance) OR (`level`=:balanced_exp_tobe_paid)) AND `merged`=:no LIMIT 1"); $place->bindParam(':exp_tobe_paid',$exp_tobe_paid); $place->bindParam(':redonated_exp_balance',$redonated_exp_balance); $place->bindParam(':balanced_exp_tobe_paid',$balanced_exp_tobe_paid); $place->bindParam(':no',$mergestatus); $place->execute(); if($place->rowCount() > 0) { $profin = $place->fetch(); $togethelp=$profin['email'];//sponsor email $payment_time= date("Y-m-d H:i:s",strtotime(date("Y-m-d H:i:s")." +3 hours"));//adding 3hrs to the current time if($merged!=="yes"){ $gonow = $flash->prepare("UPDATE `merge` SET `receiver`=:togethelp,`payment_time`=:payment_time WHERE `sender`=:email"); $gonow->bindParam(':email',$email); $gonow->bindParam(':togethelp',$togethelp); $gonow->bindParam(':payment_time',$payment_time); if($gonow->execute()){ $up= $flash->query("UPDATE `user` SET merged='yes' WHERE `email`='$email'"); $up2= $flash->query("UPDATE `user` SET merged='yes' WHERE `email`='$togethelp'"); } }//end of if there is someone to pay header( "refresh:$numOfSecondsToReload;$currentPage"); }//end of if the time is greater } //end of assign sponsor to user ?> . but the script i have doesnt allow them stay till 15mins. if you refresh the page twice it will assign someone to them which is not what i want. This is my script Fixed . Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now