My problem is that the 2 dates won't compare or atleast not good.
I tried most of the answers of Comparing two dates. But none of them was a succes.
What I have right know:
else if ($_SESSION['org_id'] != "0" && $_SESSION['part_id'] == 0) {
require '../conn.php';
$sql = "SELECT `end_date` FROM `partner_subscriptions` WHERE `user_id` = '" . $dUsrId . "'";
$result1 = mysqli_query($conn, $sql );
$row = mysqli_fetch_array($result1);
if (date('Y-m-d') >= $row['end_date']) {
header('Location: ../../index');
} else {
header('Location: ../../partnersubscription');
}
}
One of the things I tried
else if ($_SESSION['org_id'] != "0" && $_SESSION['part_id'] == 0) {
require '../conn.php';
// header('Location: ../../partnersubscription');
$sql = "SELECT `end_date` FROM `partner_subscriptions` WHERE `user_id` = '" . $dUsrId . "'";
$result1 = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($result1);
$today = date("Y-m-d");
$expire = $row['end_date']; //from database
$today_time = strtotime($today);
$expire_time = strtotime($expire);
if ($expire_time > $today_time) {
header('Location: ../../index');
} else {
header('Location: ../../partnersubscription');
}
}
I expect when the date of today is smaller then the date of the row it will go to index otherwise it will go to partnersubscription.
My row end_date
looks like this "2019-06-06" and is DATE