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 [email protected] 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>"; 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) 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>"; 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
Archived
This topic is now archived and is closed to further replies.