arccomp Posted November 5, 2012 Share Posted November 5, 2012 I have this line of code to check for email. I need to make sure it fails if there is a number in the first location. I am adding the email address to a linux server from the form and the linux server rejects the email address if there is a number in the first location of the text field. Any help would be appreciated. public function isValidEmail($in_email) { if (empty($in_email)) { return false; } else { if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $in_email)) { return false; } else { return true; } } } Quote Link to comment https://forums.phpfreaks.com/topic/270301-email-verification-no-number-in-position-1-of-field/ Share on other sites More sharing options...
Zane Posted November 5, 2012 Share Posted November 5, 2012 (edited) There was just a topic solved on this subject http://forums.phpfreaks.com/topic/270298-if-not-email-address/#entry1390268 If you only want to check the first character then use braces to grab it and validate it if(is_int($emailInput[0])) Edited November 5, 2012 by Zane Quote Link to comment https://forums.phpfreaks.com/topic/270301-email-verification-no-number-in-position-1-of-field/#findComment-1390273 Share on other sites More sharing options...
arccomp Posted November 5, 2012 Author Share Posted November 5, 2012 There was just a topic solved on this subject http://forums.phpfre...s/#entry1390268 If you only want to check the first character then use braces to grab it and validate it if(is_int($emailInput[0])) Thanks - will try this - sort of new at php. Will let you know. It seems the problem you refered to me above is different so I was a little confused by that. Quote Link to comment https://forums.phpfreaks.com/topic/270301-email-verification-no-number-in-position-1-of-field/#findComment-1390390 Share on other sites More sharing options...
arccomp Posted November 6, 2012 Author Share Posted November 6, 2012 I tried that code add to what I had attached and it breaks the site. Not quite sure where I went wrong? Thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/270301-email-verification-no-number-in-position-1-of-field/#findComment-1390459 Share on other sites More sharing options...
Pikachu2000 Posted November 6, 2012 Share Posted November 6, 2012 Surely you can do better than "it breaks the site". Quote Link to comment https://forums.phpfreaks.com/topic/270301-email-verification-no-number-in-position-1-of-field/#findComment-1390460 Share on other sites More sharing options...
arccomp Posted November 6, 2012 Author Share Posted November 6, 2012 (edited) Surely you can do better than "it breaks the site". The page with the form that includes and calls this function goes to a white screen. Trying to figure out if I can debug it. This is the code: public function isValidEmail($in_email) { if (is_int($in_email[0])) { return false; } else { if (empty($in_email)) { return false; } else { if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $in_email)) { return false; } else { return true; } } } Edited November 6, 2012 by arccomp Quote Link to comment https://forums.phpfreaks.com/topic/270301-email-verification-no-number-in-position-1-of-field/#findComment-1390461 Share on other sites More sharing options...
Pikachu2000 Posted November 6, 2012 Share Posted November 6, 2012 You missed a closing curly brace. Quote Link to comment https://forums.phpfreaks.com/topic/270301-email-verification-no-number-in-position-1-of-field/#findComment-1390462 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.