PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1847
Number of posts: 5013

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to get IP address of other server Posted by rajiv_turkar on 24 Dec 2003 at 10:39 PM
Hello All,
I am working on shopping cart..I want to know the IP address of the other server...
If someone searched my product from google and then he comes to my site..I want to know the IP address of google..The search engine may be anyone..How to accomplish this task...Please help me
rajiv
Report
Re: how to get IP address of other server Posted by DarQ on 25 Dec 2003 at 5:21 AM

$_SERVER['REMOTE_ADDR']


: Hello All,
: I am working on shopping cart..I want to know the IP address of the other server...
: If someone searched my product from google and then he comes to my site..I want to know the IP address of google..The search engine may be anyone..How to accomplish this task...Please help me
: rajiv
:

DarQ
url--> http://mark.space.servehttp.com

Report
Re: how to get IP address of other server Posted by netgert on 26 Dec 2003 at 2:45 AM
This message was edited by netgert at 2003-12-26 2:52:26

:
: $_SERVER['REMOTE_ADDR']
:


Doesn't this return the address of the client? I think the thing that should be looked for is "referrer". Most browsers send a referrer-header with URL of previous page. You can extract the host name of that URL and resolve it to IP address.

'REMOTE_ADDR'
The IP address from which the user is viewing the current page.

'HTTP_REFERER'
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

Try this:
$url = parse_url($_SERVER["HTTP_REFERER"]);
$ip = gethostbyname($url["host"]);


:
: : Hello All,
: : I am working on shopping cart..I want to know the IP address of the other server...
: : If someone searched my product from google and then he comes to my site..I want to know the IP address of google..The search engine may be anyone..How to accomplish this task...Please help me
: : rajiv
: :
:
: DarQ
: url--> http://mark.space.servehttp.com
:
:


NetGert[/italic]




Report
Re: how to get IP address of other server Posted by Johnny13 on 26 Dec 2003 at 5:33 AM
so the answer is 216.239.57.99?
Report
Re: how to get IP address of other server Posted by netgert on 26 Dec 2003 at 8:40 AM
: so the answer is 216.239.57.99?
:
Pinging google.com [216.239.57.99] with 32 bytes of data:

Yep, it's google!


NetGert[/italic]


Report
Re: how to get IP address of other server Posted by MaxLee on 6 Jan 2004 at 6:38 PM
:
: $_SERVER['REMOTE_ADDR']
:

:
: : Hello All,
: : I am working on shopping cart..I want to know the IP address of the other server...
: : If someone searched my product from google and then he comes to my site..I want to know the IP address of google..The search engine may be anyone..How to accomplish this task...Please help me
: : rajiv
: :
:
: DarQ
: url--> http://mark.space.servehttp.com
:
:


I just happen browse this thread and find the $_SERVER['REMOTE_ADDR'],it is helpful,

thx a lot.

Report
Re: how to get IP address of other server Posted by DarQ on 7 Jan 2004 at 4:44 AM
: :
: : $_SERVER['REMOTE_ADDR']
: :

: :
: : : Hello All,
: : : I am working on shopping cart..I want to know the IP address of the other server...
: : : If someone searched my product from google and then he comes to my site..I want to know the IP address of google..The search engine may be anyone..How to accomplish this task...Please help me
: : : rajiv
: : :
: :
: : DarQ
: : url--> http://mark.space.servehttp.com
: :
: :
:
:
: I just happen browse this thread and find the $_SERVER['REMOTE_ADDR'],it is helpful,
:
: thx a lot.

and that you may use it wisely

:

DarQ
NEW url--> http://mark.space.servehttp.com

Report
Re: how to get IP address of other server Posted by Johnny13 on 25 Dec 2003 at 5:44 AM
: I want to know the IP address of the other server...
I think you're looking for $ip=gethostbyname("");
yup,RTFM as they said :P
Report
Re: how to get IP address of other server Posted by DarQ on 25 Dec 2003 at 6:23 AM
This message was edited by Moderator at 2003-12-25 6:26:22

: : I want to know the IP address of the other server...
: I think you're looking for $ip=gethostbyname("");
: yup,RTFM as they said :P
:
no, gethostbyname is similar to the *nix function host IPADDRESS

see:
http://php.net/manual/function.gethostbyname.php

you would need the hostname to get the IP. what's below is simpler, faster and easier

the REAL IP comes with $_SERVER['REMOTE_ADDR']
DarQ
url--> http://mark.space.servehttp.com





Report
Re: how to get IP address of other server Posted by rajiv_turkar on 25 Dec 2003 at 9:18 PM
Hello all,
The things which u told is not solving my problem...My problem is that if someone comes to my site by using search engines like google or else...I want to know the IP address or host name of that search engine....Now i think that u understand my problem...Is there any facility in PHP to do this...Thanks 4 ur reply...
Rajiv



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.