kennyw1000 Posted January 17, 2008 Share Posted January 17, 2008 Hello everyone, I am still learning PHP, and have been tasked with modifying a script. There is a function in the script that checks to see how many times a user has sent an email within a certain period of time. I need to add a little piece that allows one user (the admin) to send an unlimited amount of emails. I thought the best way to do this was to put in a piece that basically says: with this user, skip the email count. Below is the function: //////////////////////////////////////////////// public function checkUserEmailCount($uid){ $q = "SELECT DATE_FORMAT('last_email', '%Y %c') AS last_email, email_count FROM user WHERE id=".$this->quote_smart($uid); $result = $this->query($q); $row = mysql_fetch_assoc($result); $today = (int) date('Ym'); $last_email = (int) $row['last_email']; if ($last_email < $today){ $q = "UPDATE user SET email_count=0 where id=".$this->quote_smart($uid); $result = $this->query($q); return true; } else if($row['email_count'] < MAX_FLYERS){ return true; } else { return false; } } /////////////////////////////////////////////////// I'm not sure how to do this, but I thought about adding something like this: If user ID = 285 then skip email count } else if($last_email < $today){ $q = "UPDATE user SET email_count=0 where id=".$this->quote_smart($uid); $result = $this->query($q); return true; } else if($row['email_count'] < MAX_FLYERS){ return true; } else { return false; } Any help on this would be appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/86504-php-newbie-modifying-a-simple-function/ Share on other sites More sharing options...
revraz Posted January 17, 2008 Share Posted January 17, 2008 How about if the user is the Admin then just don't run the function? Quote Link to comment https://forums.phpfreaks.com/topic/86504-php-newbie-modifying-a-simple-function/#findComment-442016 Share on other sites More sharing options...
kennyw1000 Posted January 17, 2008 Author Share Posted January 17, 2008 That is a good idea. Would that go in this function or the page that calls the function? Quote Link to comment https://forums.phpfreaks.com/topic/86504-php-newbie-modifying-a-simple-function/#findComment-442025 Share on other sites More sharing options...
revraz Posted January 17, 2008 Share Posted January 17, 2008 In the line that calls the function, before it to do a IF statement and check if its a admin. Quote Link to comment https://forums.phpfreaks.com/topic/86504-php-newbie-modifying-a-simple-function/#findComment-442058 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.