Solved

Redirecting to a url in PHP

Posted on 2000-05-09
6
201 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Wordpress syntax error 1 29
How can I split the array as 4 rows per line? 5 64
Not needed 13 58
delete database record with modal 21 34
Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now