I'm making a script, in which the user needs to enter a valid IP address. How can I check that it's a valid IP address? (Doesn't need to resolve)
Basically $_POST['ip']
just needs to be between 0.0.0.0
and 255.255.255.255
If you're running PHP >= 5.2, use the Filter extension:
filter_var($ip, FILTER_VALIDATE_IP)
More info here and here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With