Forum Moderators: coopster

Message Too Old, No Replies

run and redirect

         

gonny

4:52 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



Hi all!

Can I make a script with php first to run a url (http://address.com/path/file.php) and after run this to redirect to an other page with Head: url...

npwsol

6:00 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



Including /path/file.php would run the contents of that script, after which you could send the Location: header. Either way, you'll still have to run it from a page.

eelixduppy

6:12 am on Jun 27, 2008 (gmt 0)



>> run a url

"Running" a URL is different than what you might want. If the PHP file isn't local to your server, then using the URL for that file in an include will not include the PHP code itself, but rather the contents of the output from that script from the other server. If you'd like the actual PHP code to be included within your file before the redirect, you must use an absolute or relative path.

One other thing you should note is that if the included file sends anything to the browser then your redirect will not work as the headers would have already been sent to the browser and therefore you won't be able to modify them further. To avoid this, make sure there isn't anything being output before the header [php.net]() redirect and also in the included file. Sometimes these errors are difficult to track down if it's something like a whitespace character being output.