2016-08-12 3 views
0

문제는 내 변수 $target_time이 제대로 작동하지 않는다는 것입니다.양식 제출 후 변수가 변경되지 않습니다

if (isset($_POST['bid'])) { 
    $stmt10->execute(array(
    'user_id' => $usid, 
    'user' => $login, 
    'bid' => $_SESSION['bid'] 
)); 
} 

$target_time = strtotime('+15 minutes', strtotime($stmt14)); 
$current_time = time(); 

echo $current_time . ' >= ' . $target_time; 

$seconds_left = $target_time - $current_time; 
$minutes_left = floor($seconds_left/60); 
$seconds_left -= $minutes_left * 60; 
$seconds_left = floor($seconds_left); 

if ($current_time >= $target_time) { 
    $stmt9->execute(); 
    $r1 = $stmt9->fetch(PDO::FETCH_ASSOC); 
    $stmt12->execute();  
    $r2 = $stmt12->fetch(PDO::FETCH_ASSOC); 
    $stmt11->execute(array(
      'win' => $r1['bid'], 
      'user_id' => $r2['user_id'] 
)); 
    $stmt13->execute(); // Clears bid table 
} 

사용자 프레스 제출 버튼을, 이름 bidif (isset($_POST['bid'])) { 의해 실행되지만 $target_time$current_time 이상 아니고, 단지 대신 양식 제출 15 분을 추가 1470996804 >= 900을 실행하는 요소 값 날짜. if ($current_time >= $target_time) { 조건에 해당하는 1470996804 >= 900의 결과를 제공하므로 양식을 제출 한 직후에 실행 중이며 $stmt13->execute();이 실행되므로 모든 테이블 내용이 제거됩니다. 양식을 제출할 때 어떻게해야합니까? $target_time은 데이터베이스에서 가져오고 if ($current_time >= $target_time) { 조건은 즉시 적용되지 않지만 제출 버튼을 누른 후 15 분 후에 만 ​​실행됩니까?

+0

나는 당신이 무엇을 요구하는지 이해하기 위해 애 쓰고 있습니다. 사용자가 양식을 제출 한 후 15 분 후에 쿼리를 실행 하시겠습니까? – BadHorsie

+0

예, 정확히 원하는 것입니다. – Luke

+0

15 분 지연 대신 사용자가 양식을 제출 한 후에 오류가 표시되지 않습니다. – Luke

답변

0

나는 혼자 해결했습니다. 예, $stmt14은 PDO 문이며 실행 전에 가져옵니다. 단지이 조건을 대신 사용했습니다 : if ($current_time >= $target_time && $stmt2 >= 1) { 여기서 $stmt2은 PDO 수 계산서이므로 1 행이 있는지 확인한 다음 마지막으로 삽입 된 행의 값을 가져옵니다.

관련 문제