Solved

Redirection in PHP

Posted on 2003-11-30
5
256 Views
Last Modified: 2006-11-17
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
Comment
Question by:justmelat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9846404
if ($answer == 'good') {
  header("Location: good.html");
} else {
  header("Location: bad.html");
}
0
 
LVL 1

Author Comment

by:justmelat
ID: 9859976
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9861120
 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
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11660578
User resolved; closed, 60 points refunded.

Netminder
Site Admin
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question