Hi all this must be easy i have 5 webpage all on different domains i need to a insert some text from a different domain and display the domain name the at page is on and on not the remote site here is the code on each site = the include http://www.mydoamin.co.uk/text.php the text <?php $hostname = $_SERVER['HTTP_HOST']; $hostname = str_replace('www.','',$hostname); $hostname = str_replace('.co.uk','',$hostname); ?> ... echo hostname but this displays the host name of where the included file is located but I would like to display the domain name where the file has been called from
Probably a redirect is what you need to do. There is no way to change what the user sees the domain name as. Try: $hostname = $_SERVER['HTTP_HOST']; $hostname = str_replace('www.','',$hostname); $hostname = str_replace('.co.uk','',$hostname); header("Location: http://".$hostname.""); PHP:
Instead of including the file, use a fopen to retrieve it and then echo it into your page. That way, you can pass the current HOST to the remote script as a url parameter and retrieve it within that script using $_GET.
<?php $sites = explode("/",$_SERVER['HTTP_REFERER']); $site = $sites[2]; ?> PHP: This has worked for me most of the time.