Forum Moderators: coopster

Message Too Old, No Replies

Capture Website Name

         

sfast

6:54 pm on Oct 8, 2007 (gmt 0)

10+ Year Member



Can somebody guide me what PHP function shows the website Name .

For ex. There are two websites names with the same IP Address and their google keys to display the maps.

www.example1.com, Google Key (aaaaaaaaa)
www.example2.com Google Key (bbbbbbbbb)

Both the websites are directed to the same domain.

I want to have option on the webpage that when the webaddress is www.example1.com use its Key
else
if it is www.example2.com, use the other key.

How do I capture the website name.

[edited by: eelixduppy at 7:00 pm (utc) on Oct. 8, 2007]
[edit reason] changed to example.com [/edit]

PHP_Chimp

7:21 pm on Oct 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Im not sure if I have got the correct idea; but is this what you are after?


$keys = array('www.example1.com' => 'aaaaaaaa', 'www.example2.com' => 'bbbbbbb');
// assuming the link is coming from some sort of form with POST
if (array_key_exists($_POST['website'], $keys) === true) {
$google_key = $keys[$_POST['website'];
}
// do whatever you want with your google key.

sfast

7:34 pm on Oct 8, 2007 (gmt 0)

10+ Year Member



Thanks for replying.

But the website name is - coming from what we write in the browser address bar.

Like we have $_SERVER['REMOTE_ADDR'] to capture IP Address, I want to capture the name of the website.

coopster

8:24 pm on Oct 8, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Both the websites are directed to the same domain.

www.example1.com

www.example2.com

Actually, those are two different domains, not the same. They may have the same IP address, but definitely two completely different domains.

Either way, you might find your answer in the $_SERVER superglobal. Run this script on your site to determine:

<pre> 
<?php
print_r($_SERVER);
?>
<pre>

PHP_Chimp

10:26 pm on Oct 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




But the website name is - coming from what we write in the browser address bar.

This is what I dont get.
As if they are on your site then type www.example1.com into the browser address bar they will do to that site...so unless it is your site there is nothing that you can do, as they will no longer be on your site.
I assume that im just being dumb.

If they are referring in to you then you may be able to use the $_SERVER['HTTP_REFERER'] to get what you want, although this isnt always reliable.

phparion

5:50 am on Oct 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



study this function parse_url() [php.net]