This topic is locked

My custom code which works TOO-WELL

11/22/2008 8:45:21 PM
PHPRunner General questions
B
bochaka author

I have a piece of code to Allow only 1 post per user in any 30 day period, the problem is it works- too well. It prevents them from posting ever again. Can anyone help with this.I am including the code below. This is on my list page before display event, basically if a user has posted within 30 days the add button will not be displayed to them.
global $conn;

$flag=1;

select all dates from _name tables

$str = "select dateposted from _name where personname='".$_SESSION["UserID"]."'";

$rs = db_query($str,$conn);

while($data = db_fetch_array($rs))

if ((strtotime("now")-strtotime($data["dateposted"]))/(606024)<30 || strtotime($data["dateposted"]))

$flag=0;
if flag=1 show add button, if flag=0 hide add button if ($flag)

if ($_SESSION["UserID"]!="Guest")

if($flag)

$smarty->assign("allow_add",true);

else

$smarty->assign("allow_add",false);