xyn Posted September 30, 2006 Share Posted September 30, 2006 Hi,In my members area, i allow my members to send 15 emails aday from my site to other members, and I allow them to send1 email every 15 minutes, to make this work I have three tables1 :- Stores the timestamp1 :- 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 reachedtheir daily limit. but the problem is The time stamps will not workwith each other... Basically if i send 1 email i can send anotherinstantly after, and i have set my user to a 2 minute wait betweensending 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 More sharing options...
Gaoshan Posted September 30, 2006 Share Posted September 30, 2006 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.