Capture IP

Topics: User Forum
Feb 9, 2011 at 9:58 PM

Simple one:


Is it possible to record the IP address of the user who logs in / uses your site? If so, how?

(Genuine reasons for this guys!)

Many Thanks

Feb 10, 2011 at 11:45 AM
Edited Feb 10, 2011 at 11:47 AM

Absolutely, use:


Incidentally, you can get a list of all servervariables that you can use by going to this link:


For nostalgia's sake,  here is an old one by Calvin Hsia but built right into VFP:

Who Hit You?

When your Web server is hit from a Web site, how do you know who hit you? There are three new functions added to Foxtools that will help determine this. It also depends on whether you're on an intranet or the Internet. These functions call the Win Sockets API to resolve a remote IP Address to a host name.

I've added three functions to Foxtools that will resolve IP addresses.

    {"_WSOCKSTARTUP",    (FPFI) WSockStartup, 7,  "I,R,R,R,R,R,R"},
    {"_WSOCKCLEANUP",    (FPFI) WSockCleanup, 0,  ""},
    {"_WSOCKGETHOSTBYADDR",    (FPFI) WSockGetHostByAddr, 2,  "C,R"},

Call _WSOCKSTARTUP and _WSOCKCLEANUP to initialize/uninitialize the Winsock library. The _WSOCKGETHOSTBYADDR function takes an IP address string like "" and resolves it into the name of the machine.

// store 0 to buff1,buff2,buff3,buff4,buff5,buff6
//?_wsockstartup(256 * 1 + 1,@buff1,@buff2,@buff3,@buff4,@buff5,@buff6)
// integer version, wVersion,wHighVersion,szDescription,szSystemStatus,iMaxSockets,iMaxUdpDg
//?    _wsockgethostbyaddr("",@buff1)      &&returns 1 on success, 0 on failure
//        ?buff1                && returns the host name
// Note: if the target machine is not available, this call can take a long