+ Reply to Thread
Results 1 to 4 of 4

Thread: Redirecting with php

  1. #1
    bramil5 is offline x10Hosting Member bramil5 is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    8

    Redirecting with php

    Make sure that you put the code in the very top op you page.
    Nothing that creates ouput such as the echo or print function, or html can be above it.

    PHP Code:
    <?php
    header
    ("Location: http://yoursite.com");
    ?>
    Code should be pretty self explanatory.

    Hope this helps.

  2. #2
    13th_shadowflower is offline x10Hosting Member 13th_shadowflower is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    6

    Re: Redirecting with php

    what if I want to display something first, then redirect the user?
    like..
    this page doesn't exist. You will be redirected to the main page in x seconds

  3. #3
    LHVWB's Avatar
    LHVWB is offline Lord Of The Keys LHVWB is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Australia
    Posts
    1,308

    Re: Redirecting with php

    Its probably easier to do it with a Meta tag.
    http://www.tizag.com/htmlT/meta.php

    You would use some code like this.

    PHP Code:
    <?php

         header
    ("Refresh: 3; url=index.php");

         echo(
    "You will be redirected in 3 seconds.");
    ?>
    You can easily change the 3 if you want to change the number of seconds (0 will give you instant), and the url. Have a look at this for reference.
    http://au2.php.net/manual/en/function.header.php#80704

  4. #4
    supajason's Avatar
    supajason is offline x10 Lieutenant supajason is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    England........:-)
    Posts
    288

    Re: Redirecting with php

    the best thing to do is to use "ob_start()" at the top of the page, by using this it does send anything to the browser until you use "ob_end_flush()" this way you can echo things and if you want you can change the header.
    supajason was here

+ Reply to Thread

Similar Threads

  1. Replies: 3
    Last Post: 03-10-2008, 12:22 PM
  2. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  3. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  4. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers