The premise is that a person registers and gets 14 days for free.
After those 14 days, they must subscribe - they then get the system for 31 days.... until which time they are told to subscribe again.
Today's date as this is written on the forum is 1st October 2009.
The date of my subscription is 2050-09-24, I should therefore never be asked to subscribe - but yet today, being the 1st, I am.
Much of this code was supplied with the help of people on this forum - converting dates to time etc, to do calculations. Can someone tell me where this has gone wrong in the calculation as I don't see any problem.
Code: Select all
<?php
include "dbconn.php";
$email = $_POST['email'];
$password = $_POST['password'];
$email=mysql_real_escape_string($_POST["email"]);
$password=mysql_real_escape_string($_POST["password"]);
$result = mysql_query ("SELECT * FROM dxusers WHERE email = '$email' AND password = '$password'");
if (mysql_num_rows($result)==0)
{ echo "<meta http-equiv='Refresh' content='0 ;URL=index.html'>";}
elseif (mysql_num_rows($result)!=0)
{
while ($row = mysql_fetch_object($result))
{
$today = (date('Y-m-d'));
$regdate = strtotime("$row->datejoined");
$regdatecomplete = date( "Y-m-d", ($regdate) );
$subRegDateMicrotime = strtotime($regdatecomplete);
$fortnight = date( "Y-m-d", ($subDateRegMicrotime + (86400*14)) );
$subDateMicrotime = strtotime($row->subscribed);
$endmonth = date( "Y-m-d", ($subDateMicrotime + (86400*31)) );
$sysyear = substr("$today",-10,4);
$sysmonth = substr("$today",-5,2);
$sysday = substr("$today",-2,2);
if
(
($sysmonth == "09") ||
($today <= $fortnight) ||
($today <= $endmonth)
)
{
$user = "$row->firstname";
$id = "$row->id";
setcookie("user", $user, time()+13600);
setcookie("firstname", $row->firstname, time()+13600);
setcookie("lastname", $row->lastname, time()+13600);
setcookie("email", $email, time()+13600);
setcookie("userid", $row->id, time()+13600);
setcookie("type", $row->type, time()+13600);
mysql_query("UPDATE dxusers SET status = 'online' where email = '$email' AND password = '$password'");
if ($row->type == "admin")
{
echo "<meta http-equiv='Refresh' content='0 ;URL=index.php?page=home&menu=home&title=welcome to the dealer exchange'>";
}
elseif ($row->type == "user")
{
$resultstartup = mysql_query ("SELECT * FROM dxvehicles WHERE userid = '$id'");
if (mysql_num_rows($resultstartup)==0)
{ echo "<meta http-equiv='Refresh' content='0 ;URL=index.php?page=vehicleadd&menu=myvadd&title=sell first vehicle'>";}
elseif (mysql_num_rows($resultstartup)!=0)
{ echo "<meta http-equiv='Refresh' content='0 ;URL=index.php?page=home&menu=home&title=welcome to the dealer exchange'>";}
mysql_free_result($resultstartup);
}
if ($row->type == "advertiser")
{
echo "<meta http-equiv='Refresh' content='0 ;URL=index.php?page=advertlist&menu=advert&title=welcome to the dealer exchange: advertising'>";
}
}
else
{ echo "<meta http-equiv='Refresh' content='0 ;URL=subscribe.php?id=$row->id'>"; }
}
}
mysql_free_result($result);
mysql_close($sqlconn);
?>