chriscloyd Posted May 4, 2012 Share Posted May 4, 2012 I do not know whats going on. I have tried two different methods of validating and email and it keeps saying invalid email I have even tried to debug it by putting errors and nothing i have tried preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^", $e) and fliter_var($e, FLITER_VALIDATE_EMAIL); the email i am trying to debug is a valid one. its one I use daily. I have tried different emails and still no luck.... someone help me please! Quote Link to comment https://forums.phpfreaks.com/topic/262060-validate-email/ Share on other sites More sharing options...
noXstyle Posted May 4, 2012 Share Posted May 4, 2012 hi, zend has neat validation libraries, so does CI and you can browse the code directly on github. c'mon now, it's not that hard to find a email validation function. but anyways, try: preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/", $e); Edit: hmm wait a sec, your regex is identical to mine. apart from the domain length... which email are you trying to validate? if you have a domain like .info your regex will return false since it accepts only 3 chars to the extension. Quote Link to comment https://forums.phpfreaks.com/topic/262060-validate-email/#findComment-1342943 Share on other sites More sharing options...
scootstah Posted May 4, 2012 Share Posted May 4, 2012 I don't know if this helps or not but you misspelled "filter" twice. The function should be filter_var('[email protected]', FILTER_VALIDATE_EMAIL); Quote Link to comment https://forums.phpfreaks.com/topic/262060-validate-email/#findComment-1342947 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.