Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Redirection in PHP

Hi, I am setting up a login screen.  If my user enters the correct id and password, I want them to go to say - mainPage.htm, if they enter the wrong info, then I want them to go to badAnswer.htm.  I usually work with ASP and it has a redirection function that allows me to input the pages I want to go to and when that function line is encounter - the user is immediately take to the listed page.  Does php have some type of redirection function, if so, how does it work and how can I implement it in my site?

Thank you in advance.
0
justmelat
Asked:
justmelat
  • 2
1 Solution
 
shivsaCommented:
if ($answer == 'good') {
  header("Location: good.html");
} else {
  header("Location: bad.html");
}
0
 
justmelatAuthor Commented:
I can user the header function.  It causes problems if something is above this info.  But what I did figure out:
echo "<script>document.location.href='http://127.0.0.1/dashboard/CPLindex.htm';</script>";

I just put the javascript refernce in php's echo command.  it worked.  THanks for your help though.
0
 
shivsaCommented:
 Good to know you got the issue resolved. You can close the question by following this guidelines:

http://www.experts-exchange.com/help.jsp#hs5
0
 
NetminderCommented:
User resolved; closed, 60 points refunded.

Netminder
Site Admin
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now