Question Details

Browse

Page redirection in PHP

By kecheri - Aug. 28, 2008

Dear All,

I am a JSP programmer, trying to get my first PHP app running.

How do I redirect from one php to another. Or, whats the equivalent of Request.Redirect ? I tried Location("index.php") and it gave me the usual "Headers have already been sent" error.

Regards,
Kecheri


Answers

Add Answer
  1. By pickerel on Aug. 28, 2008

    be careful there's no any othere output before the location.


    1 Votes
  2. By rodeliosr on Aug. 29, 2008

    Alternative is to use Java Script


    0 Votes
  3. By kecheri on Aug. 30, 2008

    This is what I got from google.


    ";

    print " self.location='mynewpage.html';";

    print "";

    ?>


    0 Votes
  4. By chinaLong on Aug. 30, 2008

    google and doc


    0 Votes
  5. By tsega on Aug. 30, 2008

    It simple but there is one condition to it the file/page that would redirect the user should not have another tag, code etc before the redirect code, simply put this is what you need to do.


    That's it!


    0 Votes
  6. By tsega on Aug. 30, 2008

    Sorry the code didn't show but here is what you need to do.


    - create a new empty php file.

    - type the open and close php tag

    - in between the tags write


    "header( 'Location: http://www.yoursite.com/new_page.html' ) ;"


    - without the quotation marks of course.


    0 Votes
  7. By leehj2008 on Sep. 01, 2008

    window.location=your url.


    0 Votes
  8. By Frenzy on Sep. 02, 2008

    There are 3 ways in order to redirect to another page:


    1) send a "Location"-header in response (make sure that no content has been send before you are trying to send any header in PHP - this is the most preferred way;


    2) echo some javascript like this: echo 'window.location = 'google.com';';


    3) Use a equivalent to the 'Location' header inside your ;


    0 Votes
  9. By Frenzy on Sep. 02, 2008

    Sorry, seems like ostatic doesn't autoescape my html-parts - it just stripes them out.


    So, in no. 2 I mean <script type="text/javascript">window.location = 'google.com';</script>


    And in no. 3 - a META-tag, equivalent to the 'Location'


    1 Votes
  10. By an anonymous user on Oct. 07, 2008

    е


    0 Votes
  11. By bojianpc on Oct. 15, 2008

    USE JS


    0 Votes
  12. By qichunren on Oct. 15, 2008

    Use javascript window.location


    0 Votes
  13. By qichunren on Oct. 15, 2008

    Have you got it?


    0 Votes
  14. By ning on Oct. 16, 2008


    0 Votes
  15. By kernal on Oct. 16, 2008

    you could use javascript to do that


    0 Votes
  16. By neptune_9999 on Oct. 18, 2008

    google~


    0 Votes
Share your knowledge