Jump to content

More advanced login system


anolan13

Recommended Posts

Hello,

 

Right now my website uses a pretty basic login system with PHP and MySQL, after the person registers successfully it starts a session and everytime after he logs in if the username and password match it starts the session again as positive to let in. Well it's worked so far, very well, but now I need it so when Jack logs in Jack can only see Jacks page. See the problem? My script will keep people out of web pages but if the person is registered then he can see any page, and not just these certain pages.

 

I hope I made this clear enough. How would I go about doing this?

 

Thanks, the help is greatly appreciated.

Link to comment
Share on other sites

I am assuming you have a unique sessions registered that ties into the users unique field in the database.

 

Lets say that your unique session is the users ID. All you do on the pages that you want only that person to be able to see is something like this:

 

<?php

//The users session
$userID = "5";

//the ID to the user from the database
$row['userID'] = "5";

//check to see if the userID and database ID match up.
if ($userID == $row['userID']){
    echo "Your allowed to view this page.";
} else {
    echo "You are not allowed here.";
}

?>

 

It's kinda hard to explain without seeing your code to the page you want only that person to be able to see. Hopefully you will understand what I am trying to say though.

 

Link to comment
Share on other sites

I use

<?php
session_start();
if (@$_SESSION['auth'] !="yes")
{
header("Location: login.html");
exit();
}

 

At the top of all pages. The whole system was kind of piece parted together from tutorials and whatnot, but it works. If you know of a better script or an easier way for me to do it myself please tell!

Link to comment
Share on other sites

Better have a group of users and display a particular page for particular group of user.

You can also display some private messages like the user name,his/her photo when s/he successfully logs in

So that the page seems to be virtually private.

I think it is not possible to have a separate page for separate user at all,but only the contents can be different.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.