5 Replies - 304 Views - Last Post: 13 April 2013 - 03:30 AM Rate Topic: **--- 3 Votes

#1 brerallia  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 146
  • Joined: 21-January 13

How to determine if the person who log on is the admin?

Posted 10 April 2013 - 08:37 PM

hi everyone... i am new to php and a question goes through my mind.

first, lets assume that the website has no registration on the homepage cause im planning that when the admin can log on directly to the system then she is directed to her page and she can only register her employees. so that means no registration in the homepage and in the admins page, there is registration. so for example, the admin logs on to the system and registers a new employee to the system, she will be the one to decide what username and password she will create and will manually give the username and password to her employee. so, lets assume again that the new employee is registered to the system now and will be able to log on to the system.

new employee account
username: a
password: b

administrator account
username: admin
password: admin1

naturally i will be using php scripts right? so here the problem goes.
we all know that before we can create a text field and buttons there must be a form tag right? and in the form tag, there is the action attribute where the page goes once the login button is selected.

so if i use php then it must be:
<?php
if $_post['username'] == admin and $_post['password'] == admin1
action = adminspage.html
else if $_post['username'] == aand $_post['password'] == b
action = employee.html
else
(this is where the invalid username and password goes...)
?>


i am willing to learn and i know this code must be a bit confusing but i tried my best to learn. any help will be appreciated... thanks :)/>

This post has been edited by JackOfAllTrades: 11 April 2013 - 04:13 AM
Reason for edit:: USE CODE TAGS!!!


Is This A Good Question/Topic? 0
  • +

Replies To: How to determine if the person who log on is the admin?

#2 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

Re: How to determine if the person who log on is the admin?

Posted 10 April 2013 - 09:47 PM

what i do is create a field in my user table called permission.

i then use something like

<?php
if ($row['permission'] == "admin"{
echo "content for admin here"
}else{
echo "you do not have permission to see this content"
die();
}
?>


Was This Post Helpful? 1
  • +
  • -

#3 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,219
  • Joined: 23-August 08

Re: How to determine if the person who log on is the admin?

Posted 11 April 2013 - 04:14 AM

It's not $_post, it's $_POST.
Was This Post Helpful? 0
  • +
  • -

#4 brerallia  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 146
  • Joined: 21-January 13

Re: How to determine if the person who log on is the admin?

Posted 11 April 2013 - 06:12 PM

View PostJackOfAllTrades, on 11 April 2013 - 04:14 AM, said:

It's not $_post, it's $_POST.


yeah i know... i just kinda in a rush of typing and i am tired of typing so that is why it is post not POST

View Postiamcenz, on 10 April 2013 - 09:47 PM, said:

what i do is create a field in my user table called permission.

i then use something like

<?php
if ($row['permission'] == "admin"{
echo "content for admin here"
}else{
echo "you do not have permission to see this content"
die();
}
?>




what kind of field did you create? i dont understand..
Was This Post Helpful? 0
  • +
  • -

#5 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 404
  • View blog
  • Posts: 1,720
  • Joined: 30-April 10

Re: How to determine if the person who log on is the admin?

Posted 11 April 2013 - 07:11 PM

View Postbrerallia, on 12 April 2013 - 01:12 AM, said:

View Postiamcenz, on 10 April 2013 - 09:47 PM, said:

what i do is create a field in my user table called permission.

i then use something like

<?php
if ($row['permission'] == "admin"{
echo "content for admin here"
}else{
echo "you do not have permission to see this content"
die();
}
?>




what kind of field did you create? I don't understand..

You can create a new text field in your database that is called permissions (or what ever you want) that is set to either "admin" or "user" (or what ever user categories you need) when the user registers.

Then when you query the database check if the user is in the admin category of users. If so, show the admin content, else display the user content.

This post has been edited by laytonsdad: 11 April 2013 - 07:12 PM

Was This Post Helpful? 0
  • +
  • -

#6 brerallia  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 146
  • Joined: 21-January 13

Re: How to determine if the person who log on is the admin?

Posted 13 April 2013 - 03:30 AM

View Postlaytonsdad, on 11 April 2013 - 07:11 PM, said:

View Postbrerallia, on 12 April 2013 - 01:12 AM, said:

View Postiamcenz, on 10 April 2013 - 09:47 PM, said:

what i do is create a field in my user table called permission.

i then use something like

<?php
if ($row['permission'] == "admin"{
echo "content for admin here"
}else{
echo "you do not have permission to see this content"
die();
}
?>




what kind of field did you create? I don't understand..

You can create a new text field in your database that is called permissions (or what ever you want) that is set to either "admin" or "user" (or what ever user categories you need) when the user registers.

Then when you query the database check if the user is in the admin category of users. If so, show the admin content, else display the user content.


wow.. thanks i now understand it.. but i still need to learn data base... anyway thanks for having the time to explain it.. i appreciate it.. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1