Click here to Skip to main content
14,636,795 members
Articles » Web Development » PHP » General
Tip/Trick
Posted 20 Dec 2010

Tagged as

Stats

83.5K views
9 bookmarked

Redirecting to a page after login in PHP

Rate this:
4.38 (7 votes)
Please Sign up or sign in to vote.
4.38 (7 votes)
21 Dec 2010CPOL
Redirecting to a page after login in PHP
It's sometime required to redirect to a page if some
conditions are met. You may include an auth.php page in any
page. This auth.php handles login and if login username
and password are matched, then the user will be redirected
to the member home page using 'header'. The code is shown below:

if($password == $passwordtext)
{
$_SESSION["userid1"] = $id1;
header("Location: https://mysite.com
/members/index.php"); // redirects
}
else
{
unset($_SESSION["userid1"]);
$_SESSION["msg"] = "<li>Login Info - Username
/Password:  Incorrect Combination try again</li>";
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

mridul samadder
Software Developer self
Bangladesh Bangladesh
joomla,dnn, wordpress extensions and website developer -
http://techhelpsource.com/
http://extensions.techhelpsource.com/

Comments and Discussions

 
Questionlogging in with user type Pin
minejass9-Jul-12 16:37
Memberminejass9-Jul-12 16:37 
Questionhttp://y2be.tk Pin
theoplay14-May-12 9:50
Membertheoplay14-May-12 9:50 
GeneralReason for my vote of 5 Good hint! Pin
Ole Funch27-Dec-10 22:10
MemberOle Funch27-Dec-10 22:10 
GeneralReason for my vote of 4 Am new to PHP but the code is easy t... Pin
Sicelile27-Dec-10 9:32
MemberSicelile27-Dec-10 9:32 
GeneralI remember, for a script I was written, opera cached my redi... Pin
JH6427-Dec-10 6:48
MemberJH6427-Dec-10 6:48 
General@nguyen.. did u include the page name? like header("Location... Pin
mridul samadder23-Dec-10 9:48
Membermridul samadder23-Dec-10 9:48 
GeneralAny help ??? header("Location: https://mysite.com"); not w... Pin
nguyenchauhuyen21-Dec-10 22:09
Membernguyenchauhuyen21-Dec-10 22:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.