Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 24th, 2005, 11:43 AM
cli cli is offline
Authorized User
Join Date: May 2005
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default LOG-IN and LEVEL

Another help...i'm doing a login, and i want that if some one use a particular couple name-password,will be adressed to a page instead of another:

my table in DB is: id_admin, admin_name, admin_pass, admin_level.

$txtUser = $_POST['user'];
$txtPass = $_POST['feelpass'];
$enter = "SELECT * FROM admin WHERE user = '$txtUser' AND pass = '$txtPass' ";
$enter_q = mysql_query($enter) or die('errore nella Q_login');
//$takeme = mysql_fetch_array($enter_q);
$takemerows = mysql_num_rows($enter_q);

if( $takemerows > 0){

$takeme = mysql_fetch_array($enter_q);

if( $takeme['admin_level'] == 1 ){ 
header( 'Location: adminclientimenu.php' ); 


header('Location: index.php');

header('Location: adminmenu.php');
header('Location: index.php');
as you can see, i've a if() statemnt into the first if() that if() is completely jump-off and go always to "adminmenu.php" even if i use a couple admin_pass and admin_pass where the level is 1 it goes always to "adminmenu.php" if the couple is wrong it goes as aspect to "index.php"

What you use to make differenced log-in???

Reply With Quote
  #2 (permalink)  
Old May 25th, 2005, 07:56 AM
Friend of Wrox
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul

I've few ideas:
use switch ..case statements i.e., switch a admin level.

Secondly, adjust content of a Web page ( menus ) according to admin level rather than redirecting headers or using seperate Web page for a each member. You may ad more fields to db based on what can/can't be allowed to each admin user. Like using flags 'yes' or 'no', '1' or '0' etc. I hope, you'll do now. Ask us, if u've any question.

Reply With Quote
  #3 (permalink)  
Old May 29th, 2005, 04:30 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts

What I think you're really asking is: What is the best way to handle users and permissions?

This is a difficult issue to tackle, because the more flexible you want to make your permissions levels, the more complicated it is to design the application. You need to create a database schema that efficiently stores these permissions and know where these permissions affect your application.

For this reason, many applications only have two or three real levels of permissions. This site, for example, only has three that I can figure. There's an administrative level, a moderator level, and a regular user level.

Each level gets more restrictive. In other words, a moderator can do everything a regular user can do plus some extra stuff. An administrator can do everything a moderator can do, plus extra stuff.

This style of permissions is fairly easy to implement. You can use a numeric ID for the permissions levels. If a user's permission level is >= some number, then they have permission to do something. If it's <, they don't.

If, on the other hand, you want permissions being assigned to specific bits of functionality, things get much more complex.

For example, if you want to have a lot of different "regular users" each have priveledges that other users don't, then you have to start dealing with creating groups. Permissions are assigned to a group of users. Users can belong to many different groups.

Suppose for example that I belonged to a group of "PHP moderators". I would ONLY have moderator priveldges on the PHP forums on this site. I would NOT have moderator priveledges in, say, the C++ forums.

As you can probably imagine, this is a much tougher nut to crack, so most people settle for the simpler style. I'm a "moderator" on this site, which means that I can muck with ANY of the forums, even though I only really post to the PHP ones.

Hope this helps,

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to log to server's event log LenexaKS Access VBA 4 March 11th, 2008 12:49 PM
Can't get Log to write the Log.txt file jnbutler BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 3 July 31st, 2007 04:04 AM
AppException Class -Log Error to Event Log bekim BOOK: ASP.NET Website Programming Problem-Design-Solution 7 December 7th, 2004 01:01 PM
access level taoufik Beginning PHP 8 November 15th, 2004 04:29 AM
2-Level Menu mahulda ASP.NET 1.0 and 1.1 Basics 1 April 11th, 2004 09:29 PM

All times are GMT -4. The time now is 12:31 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.