Jump to content

email check


Collegeboox

Recommended Posts

I guess I am just looking for a wording for php code that checks to make sure @ sign is there...( i do not even know how to check to make sure the input is a number) For instance I have another form where they have to enter a phone number and I have no way of checking whether they enter 10 digit number or 10 letters...

Link to comment
https://forums.phpfreaks.com/topic/228211-email-check/#findComment-1176837
Share on other sites

if(preg_match('/^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/', $_POST['email1'], $matches) && strlen($matches[0]) === strlen($_POST['email1']))

 

Could be used like..

if(preg_match('/^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/', $_POST['email1'], $matches) && strlen($matches[0]) === strlen($_POST['email1'])){
//codes to submit registeration
} else {
echo 'Your email isn't valid';
}

 

Of course, you'll have to edit the variables to match yours.

Link to comment
https://forums.phpfreaks.com/topic/228211-email-check/#findComment-1176996
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.