Get $Url of Site Hosting Iframe?

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
mbarrio
Forum Newbie
Posts: 2
Joined: Wed May 19, 2010 4:48 pm

Get $Url of Site Hosting Iframe?

Post by mbarrio »

Okay so here is what I'm looking to do, pretty new to php as you will tell by my code :P. The code I have works great for Site1 and Site3 but is what I'm trying to accomplish is:
Site1 is hosting the site which dynamicly shows content according to Url name. Does this great. But now I would like Site2 to be just an Iframe of Site1 and have it display dynamic content for Site2 not Site1

Here is the code I have... I hope this makes sense

Code: Select all

function getDomain($url)
{
    if(filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED) === FALSE)
    {
        return false;
    }
    /*** get the url parts ***/
    $parts = parse_url($url);
    /*** return the host domain ***/
    return $parts['scheme'].'://'.$parts['host'];
}

Code: Select all

<?php
$domain = getDomain($url);
if ($domain = 'http://Site1') {$service='xxxxxx';} // show the phone numbers
if ($domain = 'http://Site2') {$service='xxxxxx';} // show the phone numbers
if ($domain = 'http://Site3') {$service='xxxxxx';} // show the phone numbers
echo '<p style="margin:0px 0px 10px 0px; font-size: 20px; font-weight:bold;"><img src="call-us.gif" alt="'.$service.' Questions" title="'.$service.' Questions" width="24" height="24" class="alignnone size-full wp-image-219" />&nbsp;&nbsp;'.$service.'</p>
<p style="margin:0px; font-size: 20px; font-weight:bold;"><img src="call-us.gif" alt="'.$service.' Questions" title="'.$service.' Questions" width="24" height="24" class="alignnone size-full wp-image-219" />&nbsp;&nbsp;'.$service.'</p>';
?>
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Get $Url of Site Hosting Iframe?

Post by AbraCadaver »

Put something in the URL of the iframe src, like:

Code: Select all

<iframe src="http://site1.com?site=site2">
Then in site1 code, something like:

Code: Select all

if(isset($_GET['site'])) {
   $domain = $_GET['site'];
}
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
mbarrio
Forum Newbie
Posts: 2
Joined: Wed May 19, 2010 4:48 pm

Re: Get $Url of Site Hosting Iframe?

Post by mbarrio »

Great I will plug that in a test it! Thank you!
Post Reply