Jump to content


Photo

Urgent problem...


  • Please log in to reply
1 reply to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 30 September 2006 - 09:35 PM

Hi,
In my members area, i allow my members to send 15 emails a
day from my site to other members, and I allow them to send
1 email every 15 minutes, to make this work I have three tables
1 :- Stores the timestamp
1 :- Stores the users limit (default 5)
1 :- Stores the users duration allowance (15 minutes)

The thing is I can get the code to see if a member has reached
their daily limit. but the problem is The time stamps will not work
with each other... Basically if i send 1 email i can send another
instantly after, and i have set my user to a 2 minute wait between
sending emails...

my code
if(!isset($_POST[username]))
{
	echo "missing";
	return false;
}
elseif(!isset($_POST[msg]))
{
	echo "missing";
	return false;
}
else
{	//Check timestamps. & Time Limits
	$date = date("d F o");
	$Sqls = mysql_query("SELECT mail_stamp,mail_time,mail_limit FROM accounts WHERE usr_user='{$_SESSION['username']['usr_user']}'");
	while( $DatInf = mysql_fetch_array( $Sqls, MYSQL_NUM )){ $MailStamp = $DatInf[0]; $MailTime = $DatInf[1]; $MailLimit = $DatInf[2];}
	if( $MailLimit != "n")
{
	$Sqlm = mysql_query("SELECT * FROM emails WHERE date='$date'");
	$Num1 = mysql_num_rows( $Sqlm );
	if( $Num1 == "$MailLimit" )
{
	echo 'limit ended';
	return false;
	}
}
elseif( $MailTime != "never")
{	
	$now = date("j, m, Y - H:i.s", strtotime("now"));
	if( $now < "$MailStamp" )
{
	echo 'error';
	return false;
	}
  }
}


#2 Gaoshan

Gaoshan
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 30 September 2006 - 11:18 PM

I have a few questions before I can help you out.
1. What is an example of a specific value for $mailstamp?
2. Why do you use $now = date("j, m, Y - H:i.s", strtotime("now")); rather than something simpler like $now = time(); ?

You don't need the double quotes around your variables. You have: if( $now < "$MailStamp" ) just use: f( $now < $MailStamp ).

You have if Mailimit, elseif Mailtime and then nothing. You need to return some sort of value at the end in case the previous if statements are not met.

Last, you start off with if isset, elseif isset. Try a simpler:
if(!isset($_POST[username]) || !isset($_POST[msg]))
{	
echo "missing";	
return false;
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users