Go Back   Forum Care Forums > Development Reference Area > Php Development

Reply
 
LinkBack Thread Tools Display Modes
email validation string.
Old
  (#1)
Don
Guest
 
Posts: n/a
Default email validation string. - 05-14-2007, 03:35 AM

I'm trying to get this line to validate an email address from a form and it
isn't working.

if (ereg("^.+@.+\..+$",$submittedEmail))



The book I'm referencing has this line

if (ereg("^.+@.+\\..+$",$submittedEmail))



Anyway.. I welcome any advice as long as it doesn't morph into a political
debate on ADA standards and poverty in Africa. :-)



Thanks



Don


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: [PHP] email validation string.
Old
  (#2)
Roman Neuhauser
Guest
 
Posts: n/a
Default Re: [PHP] email validation string. - 05-14-2007, 03:35 AM

# EMAIL REMOVED / 2007-01-18 06:07:24 -0800:
> I just got this from: http://php.net/preg_match
>
> <?php
> if(eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,6}$", stripslashes(trim($someVar))))


That would reject many of my email addresses. This is more in line with
the standards:

http://marc.theaimsgroup.com/?l=post...2299412819&w=2

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] email validation string.
Old
  (#3)
Nick Stinemates
Guest
 
Posts: n/a
Default Re: [PHP] email validation string. - 05-14-2007, 03:35 AM

I just got this from: http://php.net/preg_match

<?php
if(eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,6}$", stripslashes(trim($someVar))))
{
echo "good";
}
else
{
echo "bad";
}
?>


Hope it works out for you.
- Nick Stinemates

On Thu, Jan 18, 2007 at 01:40:36PM -0700, Don wrote:
> I'm trying to get this line to validate an email address from a form and it
> isn't working.
>
> if (ereg("^.+@.+\..+$",$submittedEmail))
>
>
>
> The book I'm referencing has this line
>
> if (ereg("^.+@.+\\..+$",$submittedEmail))
>
>
>
> Anyway.. I welcome any advice as long as it doesn't morph into a political
> debate on ADA standards and poverty in Africa. :-)
>
>
>
> Thanks
>
>
>
> Don
>

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] email validation string.
Old
  (#4)
'Roman Neuhauser'
Guest
 
Posts: n/a
Default Re: [PHP] email validation string. - 05-14-2007, 03:35 AM

Don't top-post.
Trim quoted material.
Use a mail user agent that doesn't screw up quoting. There's a plugin
for Outlook to fix it.
Thanks.

# EMAIL REMOVED / 2007-01-19 12:15:15 +0200:
> From: Roman Neuhauser [private.php?do=newpm&u=]
> > # EMAIL REMOVED / 2007-01-19 10:55:21 +0200:
> > > Try this : http://www.weberdev.com/get_example-3274.html

> >
> > This will reject addresses that use greylisting, and 600 lines in a single
> > function is gross. I wouldn't touch that.


I should have also mentioned that the function is fundamentally flawed,
and the whole section dealing with deliverability should be removed.
The only way to reliably find out about an email address deliverability
is to send it a secret and receive it back (filtering out bounces).
This mathematician, Daniel Bernstein, has a proof-of-concept code in
ezmlm. (Or just google for VERP.)

> You can always go to http://www.weberdev.com/ and write "email validation"
> in the Top Ajax search box.


What's "Top Ajax"?

> There are many other email validators that should have less than 600
> lines in one function


I already have a regular expression that matches a reasonable subset of
the grammar defined in RFC 822. Why should I use someone else's square
wheel when I have mine own?

Also, if there are many email validators with better code, please offer
those better ones if you must.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] email validation string.
Old
  (#5)
Roman Neuhauser
Guest
 
Posts: n/a
Default Re: [PHP] email validation string. - 05-14-2007, 03:35 AM

# EMAIL REMOVED / 2007-01-19 10:55:21 +0200:
> From: Don [private.php?do=newpm&u=]
> > I'm trying to get this line to validate an email address from a form and it
> > isn't working.
> >
> > if (ereg("^.+@.+\..+$",$submittedEmail))
> >
> > The book I'm referencing has this line
> >
> > if (ereg("^.+@.+\\..+$",$submittedEmail))


1. Why did you remove the backslash? (the original was correct)
2. What do you expect the regexp to match?
3. Define "it isn't working".

> Try this : http://www.weberdev.com/get_example-3274.html


This will reject addresses that use greylisting, and 600 lines
in a single function is gross. I wouldn't touch that.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] email validation string.
Old
  (#6)
Nuno Oliveira
Guest
 
Posts: n/a
Default Re: [PHP] email validation string. - 05-14-2007, 03:35 AM

>
> 1. Why did you remove the backslash? (the original was correct)
>

I have a regular expression tester plugin in firefox and it validates Ok
with the expression he provided.

If I add the second (original) backslash it won't validate emails anymore.

Also, from my little knowledge of Red.Exp. the backslash will escape special
chars.
In this case the backslash will escape the dot to match only a dot and not
all chars...

This my way of seing it...
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
RE: [PHP] email validation string.
Old
  (#7)
bruce
Guest
 
Posts: n/a
Default RE: [PHP] email validation string. - 05-14-2007, 03:35 AM

hi...

the real problem you have with email validation is that the vast majority of
the email validation scripts that you see in various apps only handle a part
of what the wc3/spec states to be valid email addresses.

if your app had the ability to handle the time constraint, a reasonable
approach would be to simply fire off a msg to the email address and check
the return status code! if you're really going to try to get a function to
validate email addresses, and you're concerned about the outlying address
types, then you're going to wind up with an ugly/hairy/complex situation.

awhile ago, in taking the path least traveled, i punted this issue, and used
a 'perl' function that i call from php to handle it... does it take a little
longer, sure... but i decided it was worth it....


peace..



-----Original Message-----
From: Roman Neuhauser [private.php?do=newpm&u=]
Sent: Friday, January 19, 2007 2:17 AM
To: WeberSites LTD
Cc: 'Don'; php-EMAIL REMOVED
Subject: Re: [PHP] email validation string.


# EMAIL REMOVED / 2007-01-19 10:55:21 +0200:
> From: Don [private.php?do=newpm&u=]
> > I'm trying to get this line to validate an email address from a form and

it
> > isn't working.
> >
> > if (ereg("^.+@.+\..+$",$submittedEmail))
> >
> > The book I'm referencing has this line
> >
> > if (ereg("^.+@.+\\..+$",$submittedEmail))


1. Why did you remove the backslash? (the original was correct)
2. What do you expect the regexp to match?
3. Define "it isn't working".

> Try this : http://www.weberdev.com/get_example-3274.html


This will reject addresses that use greylisting, and 600 lines
in a single function is gross. I wouldn't touch that.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
RE: [PHP] email validation string.
Old
  (#8)
WeberSites LTD
Guest
 
Posts: n/a
Default RE: [PHP] email validation string. - 05-14-2007, 03:35 AM

You can always go to http://www.weberdev.com/ and write "email validation"
in the Top Ajax search box. There are many other email validators that
should have less than 600 lines in one function

berber

-----Original Message-----
From: Roman Neuhauser [private.php?do=newpm&u=]
Sent: Friday, January 19, 2007 12:17 PM
To: WeberSites LTD
Cc: 'Don'; php-EMAIL REMOVED
Subject: Re: [PHP] email validation string.

# EMAIL REMOVED / 2007-01-19 10:55:21 +0200:
> From: Don [private.php?do=newpm&u=]
> > I'm trying to get this line to validate an email address from a form
> > and it isn't working.
> >
> > if (ereg("^.+@.+\..+$",$submittedEmail))
> >
> > The book I'm referencing has this line
> >
> > if (ereg("^.+@.+\\..+$",$submittedEmail))


1. Why did you remove the backslash? (the original was correct) 2. What do
you expect the regexp to match?
3. Define "it isn't working".

> Try this : http://www.weberdev.com/get_example-3274.html


This will reject addresses that use greylisting, and 600 lines in a single
function is gross. I wouldn't touch that.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
RE: [PHP] email validation string.
Old
  (#9)
WeberSites LTD
Guest
 
Posts: n/a
Default RE: [PHP] email validation string. - 05-14-2007, 03:35 AM

Top Ajax :
I meant that at the top of WeberDev.com there is an Ajax search box that you
can use
to search for "email validation" and see many related code examples to
choose from.

berber

-----Original Message-----
From: 'Roman Neuhauser' [private.php?do=newpm&u=]
Sent: Friday, January 19, 2007 1:47 PM
To: WeberSites LTD
Cc: 'Don'; php-EMAIL REMOVED
Subject: Re: [PHP] email validation string.

Don't top-post.
Trim quoted material.
Use a mail user agent that doesn't screw up quoting. There's a plugin for
Outlook to fix it.
Thanks.

# EMAIL REMOVED / 2007-01-19 12:15:15 +0200:
> From: Roman Neuhauser [private.php?do=newpm&u=]
> > # EMAIL REMOVED / 2007-01-19 10:55:21 +0200:
> > > Try this : http://www.weberdev.com/get_example-3274.html

> >
> > This will reject addresses that use greylisting, and 600 lines in a
> > single function is gross. I wouldn't touch that.


I should have also mentioned that the function is fundamentally flawed, and
the whole section dealing with deliverability should be removed.
The only way to reliably find out about an email address deliverability is
to send it a secret and receive it back (filtering out bounces).
This mathematician, Daniel Bernstein, has a proof-of-concept code in ezmlm.
(Or just google for VERP.)

> You can always go to http://www.weberdev.com/ and write "email validation"
> in the Top Ajax search box.


What's "Top Ajax"?

> There are many other email validators that should have less than 600
> lines in one function


I already have a regular expression that matches a reasonable subset of the
grammar defined in RFC 822. Why should I use someone else's square wheel
when I have mine own?

Also, if there are many email validators with better code, please offer
those better ones if you must.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
RE: [PHP] email validation string.
Old
  (#10)
WeberSites LTD
Guest
 
Posts: n/a
Default RE: [PHP] email validation string. - 05-14-2007, 03:35 AM

Try this : http://www.weberdev.com/get_example-3274.html

berber

-----Original Message-----
From: Don [private.php?do=newpm&u=]
Sent: Thursday, January 18, 2007 10:41 PM
To: php-EMAIL REMOVED
Subject: [PHP] email validation string.

I'm trying to get this line to validate an email address from a form and it
isn't working.

if (ereg("^.+@.+\..+$",$submittedEmail))



The book I'm referencing has this line

if (ereg("^.+@.+\\..+$",$submittedEmail))



Anyway.. I welcome any advice as long as it doesn't morph into a political
debate on ADA standards and poverty in Africa. :-)



Thanks



Don
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top