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

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

Redirecting to a url in PHP

Hej,

I would like to redirect from a page to another. I tried to use the html tag
<META HTTP-EQUIV='REFRESH' CONTENT='3; URL=newpage.html'>
but it does not work.

Is there a way to do a redirect in PHP?

Thanks
Stephane
0
stephaneeybert
Asked:
stephaneeybert
  • 3
  • 2
1 Solution
 
chkassenCommented:
Hi

You can redirect with php using the header() function.

Your code should look as this:
header("Location: http://www.php.net");  /* Redirect browser to PHP web site */
exit;  /* Make sure that code below does not get executed when we redirect. */

Greetings
--
chkassen
0
 
us111Commented:
Easy in PHP

<?
  header("Refresh:3;newpage.html");
?>
0
 
stephaneeybertAuthor Commented:
Thanks guys. Who wants the points?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
us111Commented:
I think my comment answers your question
<META HTTP-EQUIV='REFRESH' CONTENT='3; URL=newpage.html'> ... :))

Be careful, before the header function, you musn't stdout something otherwise it won't work.
0
 
stephaneeybertAuthor Commented:
Thanks for all your comments.

The only thing new that I got from you guys, is from "chkassen", who tipped me first about the function "header()". Unfortunately, I cannot use this function in my application, because I want to output some warning message for a few seconds before doing the redirection.

The html tag I was using didn't work, because there was a <style> tag and a <div> tag on the same page for a layer. It seems that when there is a layer on a page, the <meta http-equiv> tag cannot be used. One more html bug?

So I removed my layer, and now I can do the redirection using my <meta http-equiv> tag.

But anyway here are the points.

Thanks
0
 
stephaneeybertAuthor Commented:
Cheers!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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