Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. How can I redirect web page with PHP ?

How can I redirect web page with PHP ?

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
questionjavascriptphp
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mohammad Dayyan
    wrote on last edited by
    #1

    Hi there. Do you know how I can redirect web page only with php like this code : function redirect($url, $time) { $table = "

    Please Wait ....

    "; $javascript =" setTimeout(\"redirect()\",$time); function redirect() { window.location = \"$url\"; } "; print($javascript); print($table); exit; } Sorry for my English. I'm a freshman .

    B L 2 Replies Last reply
    0
    • M Mohammad Dayyan

      Hi there. Do you know how I can redirect web page only with php like this code : function redirect($url, $time) { $table = "

      Please Wait ....

      "; $javascript =" setTimeout(\"redirect()\",$time); function redirect() { window.location = \"$url\"; } "; print($javascript); print($table); exit; } Sorry for my English. I'm a freshman .

      B Offline
      B Offline
      Bradml
      wrote on last edited by
      #2

      There is a really easy way to do this.

      <?php
      header("Location: http://google.com");
      ?>

      Make sure nothing is sent to the client before this line of code. If you need any more help check out http://au.php.net/header[^]


      Brad Australian The PHP MVP - Christian Graus on "Best books for VBscript" A big thick one, so you can whack yourself on the head with it.

      M 1 Reply Last reply
      0
      • B Bradml

        There is a really easy way to do this.

        <?php
        header("Location: http://google.com");
        ?>

        Make sure nothing is sent to the client before this line of code. If you need any more help check out http://au.php.net/header[^]


        Brad Australian The PHP MVP - Christian Graus on "Best books for VBscript" A big thick one, so you can whack yourself on the head with it.

        M Offline
        M Offline
        Mohammad Dayyan
        wrote on last edited by
        #3

        Thanks Bradml. but I know it. I want the script like upper function. for example I want redirect web page after 5 second . Do you know that? Thanks in advance

        Sorry for my English. I'm a freshman .

        B 1 Reply Last reply
        0
        • M Mohammad Dayyan

          Thanks Bradml. but I know it. I want the script like upper function. for example I want redirect web page after 5 second . Do you know that? Thanks in advance

          Sorry for my English. I'm a freshman .

          B Offline
          B Offline
          Bradml
          wrote on last edited by
          #4

          PHP is a server side language so no that is not possible. The way it is normally done is to use the code that you have above or a meta refresh tag. Check out meta refresh at wikipedia Meta_refresh[^]


          Brad Australian The PHP MVP - Christian Graus on "Best books for VBscript" A big thick one, so you can whack yourself on the head with it.

          M 2 Replies Last reply
          0
          • B Bradml

            PHP is a server side language so no that is not possible. The way it is normally done is to use the code that you have above or a meta refresh tag. Check out meta refresh at wikipedia Meta_refresh[^]


            Brad Australian The PHP MVP - Christian Graus on "Best books for VBscript" A big thick one, so you can whack yourself on the head with it.

            M Offline
            M Offline
            Mohammad Dayyan
            wrote on last edited by
            #5

            Thanks Bradml.

            Sorry for my English. I'm a freshman .

            B 1 Reply Last reply
            0
            • M Mohammad Dayyan

              Thanks Bradml.

              Sorry for my English. I'm a freshman .

              B Offline
              B Offline
              Bradml
              wrote on last edited by
              #6

              No problem.


              Brad Australian The PHP MVP - Christian Graus on "Best books for VBscript" A big thick one, so you can whack yourself on the head with it.

              1 Reply Last reply
              0
              • B Bradml

                PHP is a server side language so no that is not possible. The way it is normally done is to use the code that you have above or a meta refresh tag. Check out meta refresh at wikipedia Meta_refresh[^]


                Brad Australian The PHP MVP - Christian Graus on "Best books for VBscript" A big thick one, so you can whack yourself on the head with it.

                M Offline
                M Offline
                Mohammad Dayyan
                wrote on last edited by
                #7

                Thanks Bradml. your answer was great. You're nice ;)

                Sorry for my English. I'm a freshman .

                B 1 Reply Last reply
                0
                • M Mohammad Dayyan

                  Thanks Bradml. your answer was great. You're nice ;)

                  Sorry for my English. I'm a freshman .

                  B Offline
                  B Offline
                  Bradml
                  wrote on last edited by
                  #8

                  Glad to here it. Welcome to the Code Project community.


                  Brad Australian The PHP MVP - Christian Graus on "Best books for VBscript" A big thick one, so you can whack yourself on the head with it.

                  1 Reply Last reply
                  0
                  • M Mohammad Dayyan

                    Hi there. Do you know how I can redirect web page only with php like this code : function redirect($url, $time) { $table = "

                    Please Wait ....

                    "; $javascript =" setTimeout(\"redirect()\",$time); function redirect() { window.location = \"$url\"; } "; print($javascript); print($table); exit; } Sorry for my English. I'm a freshman .

                    L Offline
                    L Offline
                    luayessa
                    wrote on last edited by
                    #9

                    1- Install the PECL library. 2- use the function "http_redirect".

                    M 1 Reply Last reply
                    0
                    • L luayessa

                      1- Install the PECL library. 2- use the function "http_redirect".

                      M Offline
                      M Offline
                      Mohammad Dayyan
                      wrote on last edited by
                      #10

                      Thank you. I used this function. I think this is better.

                      function redirect($url, $time)
                      {
                      $table = "
                      <html>
                      <head>
                      <META http-equiv=\"refresh\" content=\"$time;URL=$url\">
                      </head>
                      <body bgcolor=\"#847d6d\">
                      <div style=\"background-color:#ECE9D8; width:250px; margin:0px auto; text-align:center;\">
                      Please Wait .... <img align=\"absmiddle\" src=\"../template/default/Image/ProgressBar.gif\">
                      </div>
                      </body>
                      </html>";
                      print($table);
                      exit;
                      }

                      Freshman

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups