0

I currently have this code in my login script to check if the users subscription is in date:

// get the current date
$now = date("Y-m-d");
    if ($user_id['enddate'] < $now) {
      ?>
      <p>your Licence is out of date</p>
      <?php
      }
else
      {
      ?>
      <p>your licence is in date</p>
      <?php
      }

The value storing the expiry date is 'enddate'.

It just goes straight to the out of date message, whether the user has a subscription in date or not. I can't get my head around it.

The MYSQL field for enddate is just type 'date', and is generated from the registration script:

$enddate = date("Y-m-d", strtotime("+ 365 day"));

Any ideas? I know i'm working in depreciated MYSQL, but I need to for this project.

Cheers

4

2 回答 2

0

仅供参考:解决了以下问题:

$expirydate = mysql_query("SELECT enddate FROM users WHERE user_id = '".$_SESSION["user_id"]."'"); echo $query;
$expirydate2 = mysql_result($end, 0);
$now = strtotime(date("Y-m-d"));
if (strtotime($expirydate2) < $now) {

希望这对你们中的一些人有所帮助。

于 2013-04-18T16:44:11.793 回答
0

您需要转换为时间,日期只是一个字符串......

$now = strtotime(date("Y-m-d"));
if (strtotime($user_id['enddate']) < $now) {
  ?>
  <p>your Licence is out of date</p>
  <?php
  }
else
  {
  ?>
  <p>your licence is in date</p>
  <?php
  }
于 2013-04-17T23:25:53.887 回答