How to have a control over normal user's functions by a power user using php?
I have made a simple system using php and mysql. There are two types of users on my system - one normal-users (user) and another power-users (admin). The functionality of normal user is uploading file to web 开发者_如何学Cserver by selecting a category from a drop down list which is imported from mysql database table and each category has a power user who should have control over the normal-user's file uploading function i.e. disabling the respective category from power-user's page.
following is my conditions after login for admin, user and guest.
if isAdmin{
//admin functions!!;
}
else if isUser{
//file upload functions!!;
}
else{
//redirect to index.php;
}
How should I write a new function for admin that can enable or disable a specific category from the list?? the function should enable the particular category until the date defined by admin. the code is for category option for user.
$query="SELECT cat_name,id FROM Category";
$result = mysql_query ($query);
echo "<select name=category value=''>Category</option>";
while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[id]>$nt[name]</option>";
}
echo "</select>";//
Please someone guide me here with this. Thanks.
You might have to define some new fields in your database. Lets say 'limit_date' (which is the limit you need for the category to display) and 'isDisabled' (to display if the category is enabled or not by the admin by his wish.
Now when building the menu just check if value of the 'isDisabled' field in the database, and also if the current date has passed the date in the limit_date. If both come false then build the menu for that category else make the 'isDisabled' value in the database against that category to true and the 'limit_date' field to (NULL).
For your admin functions to enable or disable the category; For enabling ask the limit in terms of date till when you want to show the category and fire the query in the database setting the 'limit_date' to the date entered by the admin and 'isDisabled' flag to false. Vice versa in case for disable category function.
精彩评论