Jump to content

Urgent problem...


xyn

Recommended Posts

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
[code=php:0]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;
}
  }
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/22616-urgent-problem/
Share on other sites

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:
[code]if(!isset($_POST[username]) || !isset($_POST[msg]))
{
echo "missing";
return false;
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/22616-urgent-problem/#findComment-101635
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.