OK, I have gone in and played with things...... I couldn't test the DateDiff() function in MySQL, because I have version 4.0.16, and that function wasn't added until 4.1.1.
So, having said that, it was back to the drawing board. I played with your code, and was able to get it to work on my computer... Check your code, and add parenthesis around your date_add comparison like so:
$SQL="SELECT regdate, last_login FROM users WHERE username='".$_POST['username']."' AND [b]([/b]DATE_ADD(regdate, INTERVAL 30 DAY[b])[/b] > last_login)";
if(mysql_num_rows(mysql_query($SQL))>0){
print "<script type=\"text/javascript\">window.location = \"home.php?page=manage&action=billing\";</script>";
} else {
print "<script type=\"text/javascript\">window.location = \"home.php?page=manage\";</script>";
}
To test the code, so you don't have the redirects occuring (which can be frustrating, take out the prints in the if/else, and just echo a yes or no. This way, you can test to make sure you get the desired results. Once you know the right path is followed based on the select criteria, you can add back in your print statements, and check the redirects... (Just makes it easier to test things out)
For future reference... it is sooooooo much easier to pull out your dates first, and then do the comparisons in php, but the date_add() should work for you if you make the changes I described.
For example:
$getdiff = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'");
$gotdiff = mysql_fetch_array($getdiff);
$datereg = explode("-", $gotdiff['regdate']);
$regdate = date("U", mktime(0,0,0,$datereg[1],$datereg[2],$datereg[0]));
$datelogin = explode("-", $gotdiff['last_login']);
$logindate = date("U", mktime(0,0,0,$datelogin[1],$datelogin[2],$datelogin[0]));
$difference = $logindate-$regdate;
IF($difference > 2592000){
print "<script type=\"text/javascript\">window.location = \"home.php?page=manage&action=billing\";</script>";
} else {
print "<script type=\"text/javascript\">window.location = \"home.php?page=manage\";</script>";
}
There is a bit more to the php coding itself, as you can see, but you don't have to think about the MySQL at all. This way, you just pull your data, and run with it. I don't know, every person kind of sees things a bit differently I guess, but I have always found it easier to use php functionality if it can do it, as opposed to using MySQL to do the work for you.
Either way, good luck, and let me know how it turns out for you.