nutt318 Posted December 20, 2007 Share Posted December 20, 2007 For some reason this is not working and I suck at regex crap. Is there a reason why im getting back 'invalid email address' when using a test@test.com This should work right? if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $userEmail)) { echo "<h3>Invalid Email Address</h3>"; echo "<a href='javascript:history.back(1);'>Back</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/82570-solved-preg_match-checking-valid-email-address/ Share on other sites More sharing options...
revraz Posted December 20, 2007 Share Posted December 20, 2007 Verify you are using the correct variable, $userEmail. Variables are case sensitive. If so, try this regex instead ("/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$/", $userEmail) Quote Link to comment https://forums.phpfreaks.com/topic/82570-solved-preg_match-checking-valid-email-address/#findComment-419752 Share on other sites More sharing options...
nutt318 Posted December 20, 2007 Author Share Posted December 20, 2007 Of course, I messed up, It should have been. I missed the capitol letter. DOH if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $useremail)) { echo "<h3>Invalid Email Address</h3>"; echo "<a href='javascript:history.back(1);'>Back</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/82570-solved-preg_match-checking-valid-email-address/#findComment-419759 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.