I am writing a member driven portal, and a part of that is a private messaging system. I am using PHP and a MySQL database (pretty standard). Before a private message is allowed to be sent, I need to make sure that the user trying to send this message can bypass the recipient's filter. The filter is based on a few variables, including the person's age, sex, location, etc. For the simplicity of this example, let's use those three varaibles. I was considering doing it like this: In the user control panel, have a bunch of dropdown boxes specifying the values for each of the filter variables. In this case, it's $agefrom, $ageto, and $location. Once the form is submitted, I would do something like this:
Code: Select all
$filter = $_POST['agefrom'].$_POST['ageto'].$_POST['location'];
mysql_query ("INSERT INTO `filters` (`id`, `filter`) VALUES ({$_SESSION['id']}, '$filter')");Code: Select all
//assume that $user is an array of user information
$result = mysql_fetch_assoc(mysql_query("SELECT * FROM `filters` WHERE `id` = '{$_POST['recipient']}'"));
if (strstr($result['filter'], $user['sex']) && strstr($result['filter'], $user['location'])){
//send
}
else {
//don't send
}Thanks!