anolan13 Posted July 16, 2007 Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 16, 2007 Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
anolan13 Posted July 16, 2007 Author Share Posted July 16, 2007 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! Quote Link to comment Share on other sites More sharing options...
rameshfaj Posted July 16, 2007 Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.