<?php
//These came from my database
$_SESSION['dateOfMembershipEnds'] = $row['dateOfMembershipEnds'];
if(empty($email)){
echo '<script>alert("Email is required!")</script>';
}else if(empty($password)){
echo '<script>alert("Password is required!")</script>';
}else if(strtotime($_SESSION['dateOfMembershipEnds']) >= date("Y-m-d")){
echo '<script>alert("Your Subscription Mr/Ms: '.$_SESSION['username'].' is already expired") </script>';
?>
I am expecting in my code that if the membership date is already expired the statement in my else if statement should be run.
2
Answers
You’re comparing
strtotime
withdate()
which will not give you results. Try this code and see if it works:Also not relevant to your question, It seems like it may be more logical for all of these statements to be just
if
statements and not useelse if
.You can do it dateformat like this before compare
The code will look like this