marcus Posted December 17, 2006 Share Posted December 17, 2006 how would i go about checking to see if the IP given is in correct format#dot#dot#dot# Quote Link to comment Share on other sites More sharing options...
trq Posted December 17, 2006 Share Posted December 17, 2006 [code=php:0]$ip = '192.168.0.1';if (preg_match('\b(((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])(\b|\.)){4}',$ip) { // valid.}[/code] Quote Link to comment Share on other sites More sharing options...
marcus Posted December 17, 2006 Author Share Posted December 17, 2006 Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/marcus/public_html/admin/banip.php on line 17The IP provided is not valid Quote Link to comment Share on other sites More sharing options...
trq Posted December 17, 2006 Share Posted December 17, 2006 Sorry, might try something simpler.[code=php:0]if (ereg('[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}',$ip)) { // valid}[/code] Quote Link to comment Share on other sites More sharing options...
marcus Posted December 17, 2006 Author Share Posted December 17, 2006 Thanks! Works like a charm, +karma for you, haha. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.