Click here to Skip to main content
11,490,282 members (63,648 online)
Click here to Skip to main content

Tagged as

Redirecting to a page after login in PHP

, 21 Dec 2010 CPOL 40.6K 8
Rate this:
Please Sign up or sign in to vote.
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 17:37
memberminejass9-Jul-12 17:37 
Questionhttp://y2be.tk Pin
theoplay14-May-12 10:50
membertheoplay14-May-12 10:50 
GeneralReason for my vote of 5 Good hint! Pin
Ole Funch27-Dec-10 23:10
memberOle Funch27-Dec-10 23:10 
GeneralReason for my vote of 4 Am new to PHP but the code is easy t... Pin
Sicelile27-Dec-10 10:32
memberSicelile27-Dec-10 10:32 
GeneralI remember, for a script I was written, opera cached my redi... Pin
JH6427-Dec-10 7:48
memberJH6427-Dec-10 7:48 
General@nguyen.. did u include the page name? like header("Location... Pin
mridul samadder23-Dec-10 10:48
membermridul samadder23-Dec-10 10:48 
GeneralAny help ??? header("Location: https://mysite.com"); not w... Pin
nguyenchauhuyen21-Dec-10 23:09
membernguyenchauhuyen21-Dec-10 23:09 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150520.1 | Last Updated 21 Dec 2010
Article Copyright 2010 by mridul samadder
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid