9999 Posted August 25, 2012 Share Posted August 25, 2012 Could someone help me with these 2 lines. Many thanks in advance! if(!eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $_POST['email'])) { if(!eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $value)) { Link to comment https://forums.phpfreaks.com/topic/267565-help-with-deprecated-eregi/ Share on other sites More sharing options...
Christian F. Posted August 25, 2012 Share Posted August 25, 2012 A quick search for "differences between eregi and preg php" yielded, amongst lots other, these two results: http://www.php.net/manual/en/reference.pcre.pattern.posix.php http://docstore.mik.ua/orelly/webprog/pcook/ch13_02.htm Link to comment https://forums.phpfreaks.com/topic/267565-help-with-deprecated-eregi/#findComment-1372364 Share on other sites More sharing options...
MMDE Posted August 25, 2012 Share Posted August 25, 2012 http://www.php.net/manual/en/function.preg-match.php Just use preg_match instead, and be aware that eregi was case insensitive, while preg_match is case sensitive. It just means you need to add A-Z next to every time you use a-z, that is if you want to allow A-Z, but I suppose you do, because you were allowing that before. "^[a-zA-Z0-9\._-]+@+[a-zA-Z0-9\._-]+\.+[a-zA-Z]{2,3}$" Like that. I don't think it's a safe code to validate input, because $ only match end of line, not end of string. \Z I think is end of string, and you should also use \A at the beginning instead of ^. I also think there exists a function to validate emails without needing to use regex for it: http://www.php.net/manual/en/function.filter-var.php http://php.net/manual/en/filter.filters.validate.php http://php.net/manual/en/filter.examples.validation.php Link to comment https://forums.phpfreaks.com/topic/267565-help-with-deprecated-eregi/#findComment-1372366 Share on other sites More sharing options...
9999 Posted August 25, 2012 Author Share Posted August 25, 2012 Thanks. I got this from some old free script. Link to comment https://forums.phpfreaks.com/topic/267565-help-with-deprecated-eregi/#findComment-1372385 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.