You are here: Re: ereg statements « All PHP « IT news, forums, messages
Re: ereg statements

Posted by Koncept on 10/13/06 02:56

In article <kdqTg.75730$DB3.17407@newsfe6-gui.ntli.net>, Cerebral
Believer <nospamthanks@hadenoughalready.com> wrote:

> Is this a good ereg statement?
>
> if
>
> (!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{1,})*\.([a-z]{2,})
> {1}$",$email_1
> or $email_2))
> {
> unset($_GET['do']);
> $message_new = "<font color='#cc0000'>$email_1 or $email_2 is not a
> valid email address.
> Please try again.</font>";
> include("login_form.php");
> exit();
>
> I am just trying to check if the e-mail fields _1 & _2 on the form contain
> valid characters, without getting to complicated. The form I am using it in
> keeps returning that I am not entering a valid e-mail address, such
> "chris.bolton@ntlworld.com", or "chris@myweb.co.uk",or "chris@ntlworld.com"
> not sure why this is the case?
>
> Regards,
> C.B.
>
>


Try this:

<?php
function is_valid_email($email='') {
return (bool) preg_match( "/^
[\d\w\/+!=#|$?%{^&}*`'~-]
[\d\w\/\.+!=#|$?%{^&}*`'~-]*@
[A-Z0-9]
[A-Z0-9.-]{1,61}
[A-Z0-9]\.
[A-Z]{2,6}$/ix", $email);
}
?>

--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация