Variable isn't changing after form submitting

Luke

the problem is that my variable $target_time doesn't work well.

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
}

When user press a submit button, the element value, which name is bid is executing by if (isset($_POST['bid'])) { but the $target_time isn't more than $current_time and it just simply executing 1470996804 >= 900 instead of adding 15 minutes to the form submitting date. Because it gives the result of 1470996804 >= 900, which in the if ($current_time >= $target_time) { condition is true, it is executing immediately after submiting the form and $stmt13->execute(); is executed, so it removes all table content. What should I do to make when the form is submitted, $target_time would be taken from the database and the if ($current_time >= $target_time) { condition wouldn't be true immediately but executed only after 15 minutes when the submit button was pressed?

Luke

I've solved it by myself. Yes, $stmt14 is a PDO statement and it's fetched before the execution. Just used this condition instead: if ($current_time >= $target_time && $stmt2 >= 1) { where $stmt2 is a PDO count statement, so it makes sure there is though 1 row and then it grabs the value of the last inserted row :)

Collected from the Internet

Please contact javaer1[email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Sweetalert - validation isn't working + form is not submitting

Why isn't my form submitting

PHP - $_POST variable is not set after form submitting

HTML Form isn't submitting. Using Material Desing and Javascript

The PHP linked to this form isn't submitting entries to my database

Variable isn't changing value - PLY yacc

Why isn't my variable changing?

Form doesn't validate after submitting in moodle

Visibility of activityIndicator isn't changed after changing the value of variable which is bind with animating props

Application resets to initial screen after form submitting and changing state

Can't retrieve variable from url with Flask app after submitting search form

Form isn't submitted after checking the input

Submitting a form doesn't work after time, only after refreshing

Form clears after submitting

Why isn't my for loop in Javascript changing the variable amount?

Why isn't this code changing the variable to True Or False

In dynamic typing the existing variable's ID isn't changing in python

Form not submitting after form validation

PHP add form refreshes after submitting but doesn't insert into database

React setState doesn't update the state after submitting input form

AJAX call doesn't work after submitting a form

Can't clear the angular-json-schema-form after submitting

How do I check users email isn't already in my database when submitting a form?

Why am I getting the following warning after submitting a form using Formik: A component is changing a controlled input to be uncontrolled

Jquery form not submitting after validation

Vuetify reset form after submitting

Submitting form after validating inputs

Form not submitting after bootstrap confirmation

Loading a component after submitting a form