Jump to content

Time script not working well


Recommended Posts

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 post
Share on other sites
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...