Steve Wilkison Posted November 30, 2012 Share Posted November 30, 2012 I've been using a script to check submissions for proper email formatting. It looks like this: eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) Note, that I didn't write this script, it was provided by someone else. It's worked fine for years, but now I'm getting an error message saying the function has been deprecated. I think my host must have installed a new version of PHP, 5.3.2. That's cool, I just need to figure out what to replace this code with. I've done a little research and it seems there are several ways to approach this, including: 1. just replace "eregi" with "preg_match." 2. use "filter_var" and "FILTER_VALIDATE_EMAIL" instead. Any advice as to what would be the best way to update this script would be greatly appreciated. Thanks! Link to comment Share on other sites More sharing options...
Larry Posted November 30, 2012 Share Posted November 30, 2012 I use filter_var(). 1 Link to comment Share on other sites More sharing options...
Steve Wilkison Posted November 30, 2012 Author Share Posted November 30, 2012 Thanks, Larry. I'm going to give that a try. Out of curiosity, do you know exactly what the filter "filters?" I looked around on the web and couldn't find any specific information about this. I found that as long as I entered anything with an @ in it it worked. I thought it would also require some sort of .com/.net, etc. at the end, but it doesn't seem to. For example: swilkison (this triggers an error) swilkison@comcast (this works fine, even though there is no .net at the end) Link to comment Share on other sites More sharing options...
Larry Posted November 30, 2012 Share Posted November 30, 2012 If you look at the notes for the filters, you'll see it explained that swilkison@comcast is a valid email address format (or at least me@localhost would be). Link to comment Share on other sites More sharing options...
Steve Wilkison Posted November 30, 2012 Author Share Posted November 30, 2012 Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts