Solved

Redirecting to a url in PHP

Posted on 2000-05-09
6
276 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

730 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