how do icheck that an email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

how do icheck that an email

Post by pelegk2 »

that i have recived is a valid one?
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Send it a message?
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

ow no what i mean was how do i check for ligeal email that i recive from user when posted in a form
sorry for the miss understanding:)
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

I know what you meant.
Send the user a message, perhaps with a word of a four-digit code they need to type in on the next screen.
That way, no email, no entry.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

I think he means validate an email address

blah@blah.com - validated = yes

blf&*^&@asdas - validated = no

Mark
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Ah, but:
Matt@hsmx.com = valid
Batt@hsmx.com = invalid

The only way you can ever really know is to send the user an email with information in it.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

regex help you filter the cream from the crop and thus minimise the number of invalid email-addresses (see Mark's google link).
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Yup, i know.

The question was not well contructed in the first place by pelegk2.

Please can you read THIS and make your questions clear and concise. It makes everyones life easier.

Mark
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

i think theres still a regex in the code snipplets section that will validate the "layout" of a email address to make sure the form is correct

to make sure tis an actual address, a email validate process of some sort (as suggested)
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

yes i meant using regex
i want to check that the structure of the email that the user have types is ok
how do i do that?
agaubn sorry if i wasnt clear :)
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

There's 1001 ways to do it. Check the link i posted above for some ways of doing it.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

look in the code snipplets. heres one, not tested but looks good. quck throw-together. As mark said, u could google for this and find it alot quicker then typing a reply :)

Code: Select all

<?php
preg_match('/^їA-z0-9_\-]+ї@]їA-z0-9_\-]+(ї.]їA-z0-9_\-]+)+їA-z]{2,4}$/', $emailaddress); 
?>
this allows for a match of a-z, either cap or not. number 0-9 or _ or - followed by an @ sign, the sequence is repeated, the {2,4} makes sure a .com, .au, etc. would need modified for co.uk endings

none the less, it looks good n should work
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

ok first thanks alot
second why is the
"'/^" in the begining of the expression?
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

hello,

/ are just delimiters, it indicated the beginning of an expression pattern, they are not needed.

^ indicates the beginning of a pattern. so anything beginning with a a-z (either cap or lorwecase) or number 0-9, or a _ or -

hope this helps
Post Reply