I want to get the IP address of a visitor... how can I do this?
IP of a visitor...
There are lots of examples and caveats at http://php.net/getenv and http://php.net/manual/en/reserved.variables.php#reserved.variables.server that should help you out.
Believe it or not, I don't care about any of them. You can't protect yourself from proxies and you can't count on IP for anything else than maintaining a session (and you can't do that either because of LANs using shared connections).
Long story short:
$ip = long2ip(ip2long($_SERVER['REMOTE_ADDR']));
Note that if you're doing this for generic-recordkeeping/statistical purposes, rather than some sort of realtime or data-matching requirement, then it's already being done by the web sever.
well in Visual Basic I do this
Dim ipAddress As String = System.Net.Dns.GetHostEntry(System.Environment.MachineName.ToString()).AddressList(0).ToString()
TextBox3.Text = ipAddress
and I get a different number? why?
System.Environment.MachineName
Isn't that the name of the server? (And MachineName is already a string, so calling ToString() on it is redundant.)
I'm building a system in VB.net which will allow two computers to talk using the IP address to locate each other... which way should I find a IP address then?
If you're building it in VB.NET then why are you asking in a PHP forum?
trying to work out my system.. didn't know there was a difference in IP... is there?
There is a difference. It's like lighting a fire: if you want to do it by rubbing two sticks together then instructions on how to do it using a magnifying glass aren't going to be much help. Doesn't matter if the end result is the same.
The end result is not that same doing this and doing arp -a in command prompt gives two different results.. why?
What are the two IP addresses are you getting?
All arp does is map IP addresses on your local network to physical ethernet addresses. I fail to see what that has to do with getting the IP of a site visitor.
And you still haven't explained how this is related to PHP.
I'm not sure on what they are as I'm at work right now.. can post this later...
I'm doing a program in VB.NET but wanted PHP to return the IP address for me, I did this script and noticed there was a difference...
So which way would I use to find a user and pc in another location?
IP from VB Code
192.168.1.2
IP from PHP code
203.160.119.219
Which one is right?
Well, considering that the first one refers to a machine on the local network (and I never did receive an answer to my question about what System.Environment.MachineName was), I'd guess that the correct one for a site visitor would be the latter (it's a CallPlus Services address, if that's any clue).
Weedpacket wrote:Well, considering that the first one refers to a machine on the local network (and I never did receive an answer to my question about what System.Environment.MachineName was
I don't understand this question?
Weedpacket wrote:I'd guess that the correct one for a site visitor would be the latter (it's a CallPlus Services address, if that's any clue).
It's no clue, could you please explain this to me?
NZ_Kiwis wrote:I don't understand this question?
What does System.Environment.MachineName mean? Which bit of that question are you having trouble with? You ought to already know the answer, seeing as you're writing this program.
It's no clue, could you please explain this to me?[/quote wrote:One is an address for a machine on your local network, the other is an IP address for some machine somewhere out on the Internet. If you got confused by my saying where on the Internet, then ignore that detail.
The php due to fact that your VB script is getting the router address type it in on your browser http://192.168.1.2 and it will bring up your router home page.
Private Sub IPAddress()
'To get local address
Dim LocalHostName As String
Dim i As Integer
LocalHostName = Dns.GetHostName()
Dim ipEnter As IPHostEntry = Dns.GetHostByName(LocalHostName)
Dim IpAdd() As IPAddress = ipEnter.AddressList
For i = 0 To IpAdd.GetUpperBound(0)
Next
End Sub
bradmasterx wrote:The php due to fact that your VB script is getting the router address type it in on your browser http://192.168.1.2 and it will bring up your router home page.
No it does not for some reason?
well tht is your gateway ip ranged from 192.168..
Yeah .1.1 did find it... okay so that's the router address. What is the IP of the machine then over the entire internet?