Solved

automatic URL relocation

Posted on 2008-10-10
4
267 Views
Last Modified: 2013-12-13
Hi all,

Whilst coding with ColdFusion I have become used to using a relocate function that takes one argument, an URL of the page to relocate to. Using this function allowed for the execution of a script to jump to the start of a specified URL meaning a page could be made to automatically load another page, as if a link had been clicked by the user.

What is the equivalent in PHP I've looked all over and must be searching for the wrong function name. Can anyone help?

Cheers
0
Comment
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 125 total points
Comment Utility
There is no special function in PHP for this, but it can be done using a http Location header, created with the PHP header() function. You can not have any output to the page before this function is called.
function redirect($url) {

  header('Location: '.$url);

}

Open in new window

0
 
LVL 1

Assisted Solution

by:jarospirit
jarospirit earned 250 total points
Comment Utility
header, would redirect the user to a new page, but that is a URL redirection, if I understand the question correctly what you want its to load another page?
0
 
LVL 1

Assisted Solution

by:jarospirit
jarospirit earned 250 total points
Comment Utility
header, would redirect the user to a new page, but that is a URL redirection, if I understand the question correctly what you want it's to include a script from another page?

please load the ColdFusion function or your script to understate better

thank you.
0
 
LVL 29

Assisted Solution

by:fibo
fibo earned 125 total points
Comment Utility
Just a note "en passant": for 'header()' to work, it is important that no html code has been sent previously by the page.
A common problem is when there are spaces or empty lines before the <?php tag.
There should be none if you expect header() to work fine.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PHP and Soap 3 27
PHP Curl Setup Option 4 28
PHP loop not working 4 29
update field on focusout 15 19
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
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…

744 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

12 Experts available now in Live!

Get 1:1 Help Now