Sunday, October 20, 2019

Search IP Address With a PHP Script

Search IP Address' With a PHP Script Retrieving the users IP address is actually much simpler than you might think, and it can be done in a single line of PHP code. What the PHP script you see below does is finds the IP address of a user and then posts the address on the page that holds the PHP code. In other words, any user who visits the page will be able to see their own IP address listed there. Note:  The way this PHP script is written here does not log any IP addresses nor does it show a user anyone elses IP address - just their own. "What's My IP" PHP Script To return  the IP address of the person visiting your site, use this line: To retrieve the users IP address and then echo its value back to the user, you can use this example: Note: This is generally accurate but will not work as intended if the user is accessing your website behind a proxy. This is because the proxys IP address will be shown instead of the users true address. Test the IP Address If youre not sure that the script is working, there are numerous websites you can visit to get some other perspectives on what your IP address is being reported as. For example, after you implement the code from above, load the page and record the IP address thats given for your device. WhatsMyIP.org or IP Chicken are good places to check to see if the same IP address is recorded there.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.