/ Published in: PHP

This is a code to match an IP Address from a source.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ To use this expression follow the code below. //Save the expression in a variable. $correct_ip_format = "/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"; //some input from a user through a text field or from a server. $user_input = $_REQUEST['ip_address']; //match the two input's and save it in a variable. //Condition goes here. if(ip_match){ echo "Correct IP Address"; } else{ echo "Incorrect IP Address"; }
Comments
