You are here: How to ge the ones which are not « PHP « IT news, forums, messages
How to ge the ones which are not

Posted by Mαrio Gamito on 09/29/30 11:10

Hi,

I've built this little regular expression to test wether an e-mail
address is valid or not:

if(eregi
("^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$",
$email))
print ('valid email)
else
print ('Invalid email');

--

ok, now i want to use this in a filling form web page scenario.
I have this forms with its fields to be filled and when it gets to the
e-mail address textbox, i want to check if the address is not well formed.

So i did (notice the "!" before the eregi):

if (!eregi
("^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$",
$email))
{ send a warn to the user telling the e-mail address is not correct}

--

Well, if the first block of code works pretty good saying if an address
is valid or invalid, the second one, when the data from the filled form
is checked, always says the adress is invalid.

I thought the "!" would adapt the confition to its new scenario, but,
well... as i've told you, it isn't.

Any ideas of how to solve this, i.e., being the regular expression (and
it is), what do i have to do to get only the invalid adresses ?
In short, i only want to trap the invalid ones.

Any help would be apreciated.

Warm Regards,
MΓ‘rio Gamito

 

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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация