| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: Jun 2004 Location: United Kingdom
Posts: 2,694
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | PHP / MySQL Login Problem OK, to cut a long story short. I am trying to make a login system and am having troubles. I can make it so it logs in fine, but, here is the problem: Say a user logs in and their protected page is called client1.php. Now, when they login to access their page, if they type other secret pages filenames into their browser, they can access them with their login info. So, if client1 accessed his page (client1.php), he could also access client2's page by typing the exact filename lets say client2.php) into the browser. Now, I know there has to be a way of stopping this from happening! I think it can be done with sessions, but am not sure how. This is the code I have so far: login.php: PHP Code: PHP Code: http://www.webdesignforums.net/showt...336#post162336 So, I dunno if any of the info in that thread helps you. I brought it over to Namepros coz there are a lot more people that come online so a higher chance of quick replies. Thanks in advance, hope you understand my question. Will.
Last edited by will7; 04-09-2005 at 01:34 PM.
|
| |
| | #2 (permalink) |
| New Member Join Date: Apr 2005
Posts: 8
![]() | A different approach Just a couple of things that might help you work out your problem. First of all, at one time, I had a login page with PHP and MySQL, but I went abou the whole thing a diferent way... I had just one login page, for every user and displayed similar but individual pages for each person. Then on every other page that required a person to be logged in on, I just checked that they were with sessions. I don't know exactly how you're structuring your site, but the general idea was something like this: I had all the info about each person in a row of a MySQL table, or in some cases, in a file. Every time a person accessed this one page (lets call it login.php) their name and password was checked aginst the table. If these details were correct then a session variable was set, and they were allowed to see their area. Every other page from that point was was only available to that user if they had the session variables set. Any specific data needed was then got at the time it was required. ????: NamePros.com http://www.namepros.com/showthread.php?t=81425 Hope that helps, but let me know if it doesn't...
__________________ Adam Quaile Dancing Badger Web Design (http://www.dancingbadger.co.uk) For articles, tutorials, tips, tricks etc... on web design, programming, the web, and other similar funky stuff |
| |
| | THREAD STARTER #3 (permalink) |
| Senior Member Join Date: Jun 2004 Location: United Kingdom
Posts: 2,694
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | OK. Well, I have my main site, and then a seperate page for each web design client. These are the password protected pages. I have set sessions, but it just checks for the session and if it's on, they seem to be able to access any page. It used to be that if they typed in the exact filename then they could access it without logging in, but, with the help of sessions I stopped that. But, I can't seem to get this problem I have now sorted out. Any more help anyone? |
| |
| | #4 (permalink) |
| First Time Poster! Join Date: Apr 2005
Posts: 1
![]() | Hi, This is a common problem and you're right, sessions are the way to go... The procedure is: 1. User logs in (login.php) 2. create PHP session for user with his ip, expiring in say 20 mins 3. every page the users then visits must check that he has access to it first before displaying itself. That's the theory, now the practical: login.php: PHP Code: HTML Code: <form action="login.php" method="post"> Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password" /><br /> <input type="submit" value=" Login " /> </form> Then for each client page at the top: client.php PHP Code: logout.php PHP Code: Let us know how you get along... Cheers...
Last edited by gulfinet; 04-09-2005 at 11:19 AM.
|
| |
| | THREAD STARTER #5 (permalink) |
| Senior Member Join Date: Jun 2004 Location: United Kingdom
Posts: 2,694
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Nice one! Thank you so much gulfinet. You don't know how long I have been trying to get that sorted! Two more questions: 1) When you go to www.rednerve.com and you see the login bit? Well, how can I make it so that when a client logs in, instead of displaying that, it says "You are logged in as $username. Click here to go to your page. (And it shows a logout link too)". But it only shows it if the client is logged in and it needs to display on all the pages of the site. 2) How would I go about encrypting the important data (namely passwords) on the site? ????: NamePros.com http://www.namepros.com/showthread.php?t=81425 Thanks again for the help and I hope you can do the same with these final problems. |
| |
| | THREAD STARTER #8 (permalink) |
| Senior Member Join Date: Jun 2004 Location: United Kingdom
Posts: 2,694
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Could anyone check the thread link I posted earlier (to WDF) and check out the updates to this saga and see if they can help me? I changed the code to MD5 protect it and now it doesn't work ![]() EDIT: Here is the link and the code I am using. http://www.webdesignforums.net/showt...404#post162404 login.php: PHP Code: PHP Code: PHP Code: PHP Code: So, if anyone has the time or helpful nature to read through the thread, see what's happened and try and help me solve this, I would really, really appreciate it.
Last edited by will7; 04-10-2005 at 10:20 AM.
|
| |
| | #10 (permalink) |
| Account Closed Join Date: May 2004 Location: /etc/passwd
Posts: 2,178
![]() ![]() ![]() ![]() ![]() ![]() | if your trying to get authentication im a master with authentication, i have written around 100 different authentication systems in php alone. Use the contact information in my profile if you would like some help. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| HOWTO: Install the Apache Web Server, Perl, PHP, and MySQL on Windows | deadserious | Webmaster Tutorials | 96 | 05-27-2007 02:24 PM |
| Googlism - What does google think of you? | deadserious | The Break Room | 55 | 12-15-2005 10:09 AM |
| Tutorial: How to Install Apache2 MySQL and PHP on Windows | deadserious | Webmaster Tutorials | 35 | 09-21-2005 10:46 PM |
| Tutorial: Getting Started With MySQL (The Basics) | deadserious | Webmaster Tutorials | 3 | 04-18-2004 02:17 PM |