Solved

Redirecting to a url in PHP

Posted on 2000-05-09
6
240 Views
Last Modified: 2010-05-19
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
Comment
Question by:stephaneeybert
  • 3
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
chkassen earned 50 total points
ID: 2793427
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
 
LVL 8

Expert Comment

by:us111
ID: 2793583
Easy in PHP

<?
  header("Refresh:3;newpage.html");
?>
0
 

Author Comment

by:stephaneeybert
ID: 2795579
Thanks guys. Who wants the points?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 8

Expert Comment

by:us111
ID: 2795705
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
 

Author Comment

by:stephaneeybert
ID: 2820248
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
 

Author Comment

by:stephaneeybert
ID: 2820249
Cheers!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

810 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