Jump to content


This topic is now archived and is closed to further replies.


User Login Redirection

Recommended Posts

Hello again. 

I am trying to create a login form for users.  I'm not looking for something that will be of the highest security.  Basically, if User1 wants to login, I would want User1 to get redirected to User1's own directory.  I haven't tried putting code together, because I'm having problems finding what I should use here.  But, I can type out what I mean, it may make it easier to gain some assistance.

[code]if (user == 'user1' && pass == 'pass1');
openurl ("./user1/index.php');

elseif (user == 'user2' && pass == 'pass2');
openurl ("./user2/index.php');

openurl ("loginfailed.php');[/code]

Is there even a string that would call a URL to open, such as "openurl ("./user1/index.php');"?

Also, is there a string that I could include on all pages of a said directory, that would check to see if the user is logged in, if not direct them to the login page?

I see a lot about this, but it's worded in ways I am having problems understanding how to associate it in my own page.

Share this post

Link to post
Share on other sites
In my login script I just made it so if the login information was correct it just included a page of the members area and then I started their session. Then if they didn't have the right information it printed "Wrong username or password."


if (user == 'user1' && pass == 'pass1'){
include 'user1/index.php';

} else {
        print "Wrong login information";

Sorry if I made a mistake. I am kinda in a hurry. Try something like that.

Share this post

Link to post
Share on other sites
The function you're looking for is the header() function. Please see http://www.php.net/header


Share this post

Link to post
Share on other sites


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.