0

Hi,

I am a php newbie.

The site is a sports site, and contains information on about 10 teams. However each team has it's own admin section.
I would like to have 1 general login page that lets a user access the database that relates to their team. I don't know how to do this.
Does anyone know how? or have an example of code that would make it work? or know how the database should be set up to handle it?

I have only done a simple login system before, nothing special.

Thanks heaps,

QWaz

2
Contributors
4
Replies
8
Views
7 Years
Discussion Span
Last Post by QWaz
0

Hello,

If I understood correctly, what you need is another column in the table of the users, the column will be named team, and it should have values from 1-10 (number of teams)

when the user logs in, you should make a session for his section of the admin only (name the session variable different for each team depending on the value of the team column for that user)

I hope I was helpful, I just explained an idea in general, if you really want to get the hang of this, do the code yourself so that you can completely understand the idea.

0

Hey, theighost.

Thanks for your reply. I have another question.

I understand what you mean when you say I need to set up another column in the database, depending on the login type. However how do I make the user keep that session.

In that other login session I did, I had a session called admin, then if the person wasn't logged into it, it redirected it back to the login page. WHich is what I assume i have to do here. However, how do I get session to pass from one page to the next? and do you also mean that I have to set up 10 different session names like teamA, teamB, teamC, etc?

The other confusing issue I have is:
how do i show only the info that relates to that user? like only show teamA stuff. is that set in a cookie, or do I need to $_POST or $_GET it from one page to another??

Thanks for your help.

Cheers,

QWaz

0

Hello there,

1. you don't necessarily have to create 10 names for the session, you can create two session variables, one with the unique id of the use who is logged in (you can name this session "user_IDunique").. and another with the number of the team (you can name it "user_team").

2. Keeping the session will be done automatically, if every page has the "session_start()" function at the beginning of it.. so just put session_start() at all the pages, and the variables "user_IDunique" and "user_team" will be saved and accessible in all pages.

but remember if the use created the session and then navigated to a page that doesn't have the session_start().. then he is very likely to lose the session.

3. Getting the info related to the user logged in is very simple, you have his unique id in a session variable, you can use this id to get all his info from the database.. assuming you've designed the database correctly.

I hope that helped you.

0

Thanks mate,

You explained that very well,

Thanks for your help

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.