Jump to content


Photo

User Login Redirection


  • Please log in to reply
4 replies to this topic

#1 SelfObscurity

SelfObscurity
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts
  • LocationDetroit, MI

Posted 09 July 2006 - 10:03 PM

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.

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

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

else
openurl ("loginfailed.php');

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.

Jon Edney
Aspiring Web Developer

@JonEdney1
 


#2 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 10 July 2006 - 03:25 AM

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.


#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 10 July 2006 - 05:24 AM

The function you're looking for is the header() function. Please see http://www.php.net/header

Ken

#4 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 10 July 2006 - 06:26 AM

header("Location: http:www.example.com");
"Syntax error" .. WHERE THE **** IS IT?!

#5 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 10 July 2006 - 06:29 AM

Depends on if he wants the user to see the actual URL.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users