Jump to content

Email Verification - No Number In Position 1 Of Field


Recommended Posts

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;

}

}

}

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 by Zane

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.

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 by arccomp
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.