Its been a while since I touched programming and I decided to get back into it. But the first thing that caught my eye was the ELSE IF statement.
You have:
elseif ($expiration_date = $today)
I think it should be:
elseif ($expiration_date == $today)
The way you have it setup, I think it assigns $today to $expiration_date, but I could be wrong, its been a long time since I did this stuff.
-Pete