How to Redirect a URL in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DudeBori82
Forum Commoner
Posts: 26
Joined: Thu Nov 18, 2004 10:09 am
Location: Florida

How to Redirect a URL in PHP

Post by DudeBori82 »

I am trying to execute code in php, then when it is finished, redirect the user to a new page. Is this possible? If so, what is the code?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Once the code is parsed then it is parsed. Why not just put it at the bottom of the page?

Code: Select all

<?php
header("Location: http://www.newsite.com");

?>
DudeBori82
Forum Commoner
Posts: 26
Joined: Thu Nov 18, 2004 10:09 am
Location: Florida

Post by DudeBori82 »

OK, here's a tricky question, how do you send data back with that redirect using POST or GET and how do you control what frame it enters into? (if you are using a frame set)
peni
Forum Commoner
Posts: 34
Joined: Thu Nov 18, 2004 1:15 pm

Post by peni »

1. get - just add it like "?a=b" to the url
2. post - you can use curl in order to do it
3. what is a frame? i thought php was server-side...
DudeBori82
Forum Commoner
Posts: 26
Joined: Thu Nov 18, 2004 10:09 am
Location: Florida

Post by DudeBori82 »

What is curl?
An HTML Frameset on the target URL
peni
Forum Commoner
Posts: 34
Joined: Thu Nov 18, 2004 1:15 pm

Post by peni »

php.net/curl

a frameset exists only client-side
server-side, where php works, there are only single php pages.
Post Reply