Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Special Login Script?
Old 09-21-2007, 08:22 AM Special Login Script?
nickharper's Avatar
Extreme Talker

Latest Blog Post:
Testing this bad boy out!!!!!
Posts: 221
Name: Nick
Location: Coventry, UK
Trades: 1
Hi Guys,

Would it be possible to make a login script so that depending on the username and password they would go to a different page?

Say you login as "Keith" correctly you would go to "keith.php" and nobody else would be able to see keith.php other than whoever is logged into that account.

Then if they login as "Dave" they will go to dave.php and so on and so forth?

I have no idea where to start with this but if anybody could point me in the right direction this would be great.

Thanks

Nick
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

nickharper is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-21-2007, 09:15 AM Re: Special Login Script?
evans123's Avatar
Ultra Talker

Posts: 468
Trades: 0
Why wud u wanna do that?

you could use an if statement and show different things depending on whos logged in!
evans123 is offline
Reply With Quote
View Public Profile Visit evans123's homepage!
 
Old 09-21-2007, 09:27 AM Re: Special Login Script?
nickharper's Avatar
Extreme Talker

Latest Blog Post:
Testing this bad boy out!!!!!
Posts: 221
Name: Nick
Location: Coventry, UK
Trades: 1
Basically I want to be able to give users access to their own area on my site.

Each user will basically log into the site and then it will show their details on there, which will be simple details about their company.

I dont want each user to see the others details.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

nickharper is offline
Reply With Quote
View Public Profile
 
Old 09-21-2007, 09:57 AM Re: Special Login Script?
Average Talker

Posts: 23
Trades: 0
Hey there,

I think rather that trying to direct everyone to a different page the best idea is to direct everyone to the same page, but base the content of the page off of the users id.

Where to start create a table for the users.

User Name, Password, and a User Key that is an auto increment integer.


Then when the user logs in you call the database for their key.

after you have gotten the key put it in a variable called $usrkey

This will be the code for the redirect.

Code:
header ('Location: http:www.mydomain.com/userpage?id=$usrkey');
What this does is it adds the users key to the end of the link making that page only available to the user. And now once you are on that page you can use the key that was passed to perform the sql queries to pull up that users information and diplay it on the screen.

I hope this helps.
__________________

Please login or register to view this content. Registration is FREE
- My Site

Please login or register to view this content. Registration is FREE
- What is my ip address?
Creadiv is offline
Reply With Quote
View Public Profile Visit Creadiv's homepage!
 
Old 09-21-2007, 10:01 AM Re: Special Login Script?
nickharper's Avatar
Extreme Talker

Latest Blog Post:
Testing this bad boy out!!!!!
Posts: 221
Name: Nick
Location: Coventry, UK
Trades: 1
But with that would it be possible to change the id from say 2 to 1 and see another user's page?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

nickharper is offline
Reply With Quote
View Public Profile
 
Old 09-21-2007, 10:04 AM Re: Special Login Script?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
It's up to you to lock that.

Store in the session the authenticated user id, and make userpage.php callable without specifying any id.
The page just have to read the userId from the session.

that way, a user could only see his page, and no one else.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-21-2007, 10:04 AM Re: Special Login Script?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Instead of passing the user id as a url parameter you should keep all of the user's information (other than password) in session variables and then validate that info once they are redirected. Its a bit more secure than passing via url.


EDIT: Tripy barely beat me to it!
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 09-21-2007, 10:05 AM Re: Special Login Script?
Average Talker

Posts: 23
Trades: 0
Quote:
Originally Posted by nickharper View Post
But with that would it be possible to change the id from say 2 to 1 and see another user's page?

Good question. When they log in create a session that contains the user key as well, so that when you get to the page you check the session against the key in the url. If they don't match kick the user out to a log in screen.

Or you can do as stated above.
__________________

Please login or register to view this content. Registration is FREE
- My Site

Please login or register to view this content. Registration is FREE
- What is my ip address?

Last edited by Creadiv; 09-21-2007 at 10:06 AM..
Creadiv is offline
Reply With Quote
View Public Profile Visit Creadiv's homepage!
 
Old 09-21-2007, 10:32 AM Re: Special Login Script?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Yay !
I was the quicker !
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-21-2007, 10:37 AM Re: Special Login Script?
nickharper's Avatar
Extreme Talker

Latest Blog Post:
Testing this bad boy out!!!!!
Posts: 221
Name: Nick
Location: Coventry, UK
Trades: 1
So I have made a login script which works and now I am trying to get a Recordset on the index page using the username (thats also unique) so the PHP will drag the Record with the same username as the session variable.

The only problem is that I don't think the session variable is sent to the login page.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

nickharper is offline
Reply With Quote
View Public Profile
 
Old 09-21-2007, 10:57 AM Re: Special Login Script?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
make sure you use session_start() before you try to access any session variables. You must use it to both create a session and access a session on other pages.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 09-21-2007, 11:23 AM Re: Special Login Script?
nickharper's Avatar
Extreme Talker

Latest Blog Post:
Testing this bad boy out!!!!!
Posts: 221
Name: Nick
Location: Coventry, UK
Trades: 1
Thankyou

I think I have managed to do it now
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

nickharper is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Special Login Script?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34614 seconds with 12 queries