I’m making a form with PHP and I want to keep record of the User’s IP Addresses. This is the snip-it of code I used:
<input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
When I open the code up in XAMPP and read the source, the value had an IP address different than what was mine:
<input type="hidden" name="ip" value="::1" />
Does this IP address normally happen when I use it in a localhost (XAMPP)?
If not, are there any alternatives into grabbing the user’s IP address?
Don’t do that. Get the request from
$_SERVERwhen the form is submitted. Getting it when the form is generated and storing it in the form just gives people the opportunity to change it.Yes. Getting the local IP (IPv6) address is normal when you request a page from localhost.