query($sql); // Jos $status on 'complete' tai 'paid' niin sitten voidaan antaa asiakkaalle lisää aikaa yksi kuukausi tästä hetkestä eteenpäin tai tietokannassa olevasta valid until päivästä eteenpäin // Ensin haetaan ko asiakkaan tämänhetkinen tilauksen päättymispäivä $UserID = $mysqli->escape_string($_GET["UserID"]); $sql = "SELECT subscriptionvaliduntil"; $sql .= " FROM odemarkusers"; $sql .= " WHERE id = '".$UserID."'"; $result = $mysqli->query($sql); // echo $sql; $row = $result->fetch_row(); // echo $row; $Tulos=$row[0]; $date = date('Y-m-d',time());//date variable $time1=strtotime($Tulos); $time2=strtotime($date); // echo "Valid until:" . $Tulos ."\n"; // echo "Today:" . $date ."\n"; If ($time1>=$time2) { // Database validuntil is bigger $NewDate=$Tulos; } else { // Today is bigger $NewDate=$date; } $date = $NewDate; $newdate2 = strtotime ( '31 day' , strtotime ( $date ) ) ; $newdate2 = date ( 'Y-m-j' , $newdate2 ); // echo "New validuntil:" . $newdate2; $newvaliduntil= newdate2; // date('Y-m-d h:i:s', strtotime("+31 days")); if ($status =='complete' || $status =='paid') { $sql = "UPDATE odemarkusers SET subscriptionvaliduntil='$newvaliduntil' WHERE id =" . $customerId ." "; $mysqli->query($sql); // echo $sql; } } ?>