SelfObscurity Posted July 9, 2006 Share Posted July 9, 2006 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');elseopenurl ("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. Quote Link to comment https://forums.phpfreaks.com/topic/14121-user-login-redirection/ Share on other sites More sharing options...
pocobueno1388 Posted July 10, 2006 Share Posted July 10, 2006 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."[code]if (user == 'user1' && pass == 'pass1'){include 'user1/index.php';} else { print "Wrong login information";}[/code]Sorry if I made a mistake. I am kinda in a hurry. Try something like that. Quote Link to comment https://forums.phpfreaks.com/topic/14121-user-login-redirection/#findComment-55387 Share on other sites More sharing options...
kenrbnsn Posted July 10, 2006 Share Posted July 10, 2006 The function you're looking for is the header() function. Please see http://www.php.net/headerKen Quote Link to comment https://forums.phpfreaks.com/topic/14121-user-login-redirection/#findComment-55405 Share on other sites More sharing options...
legohead6 Posted July 10, 2006 Share Posted July 10, 2006 header("Location: http:www.example.com"); Quote Link to comment https://forums.phpfreaks.com/topic/14121-user-login-redirection/#findComment-55412 Share on other sites More sharing options...
Daniel0 Posted July 10, 2006 Share Posted July 10, 2006 Depends on if he wants the user to see the actual URL. Quote Link to comment https://forums.phpfreaks.com/topic/14121-user-login-redirection/#findComment-55414 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.