Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking mail and site 1

Status
Not open for further replies.

mcvdmvs

Technical User
Sep 18, 2000
172
NL
I am trying to check for valid email and url adresses with eregi, but i cant find out what to check: heres my code:

if(!eregi("([a-z0-9])*@([a-z0-9])*(\.[a-z0-9])*", $email))

theres one problem, does it match RFC standard? I tried finding answers on I think i miss some characters, which are valid but are not matched in the above statement.

This is the url check:
if(!eregi("^http://[a-z0-9]*(\.[a-z0-9])*", $site))

It is also not complete.
please help... MiQ
mick@nederland.net
wezine.vandermostvanspijk.nl
currently installed: html, JavaScript, dhtml, css, php, mysql, postgresql, xml, linux, apache
about to install: java, c++
 
try this
if (!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,}$", $email)) {
echo "invalid email address";
}

else
echo "valid email address";
 
thanx, im gonna get the http stuff from RFC,
works deliciously, btw '+' in username has to be added:
(!eregi("^[0-9a-z]([-_.+]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,}$", $email))

Think we made it... ;-)
mcvdmvs
mick@nederland.net

knows: html, JavaScript, dhtml, css, php, mysql, postgresql, xml, linux
to learn: java, c++, perl, python
 
wat do the 2 backslashes do?

(!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,}$", $email))
^
|
|

mcvdmvs
mick@nederland.net

knows: html, JavaScript, dhtml, css, php, mysql, postgresql, xml, linux
to learn: java, c++, perl, python
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top