$testEmail=filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
if($testEmail!==filter_input(INPUT_POST, 'email', FILTER_UNSAFE_RAW))
{
echo "email had an illegal character, please check it again.";
}
else
{
$goodEmail= filter_var($testEmail,FILTER_VALIDATE_EMAIL);
echo $goodEmail;
}
As I understand it, FILTER_VALIDATE_EMAIL (in php 5.0) allows returns,
FILTER_SANITIZE_EMAIL removes those.
This seems much simpler than using preg_xxx() - whant am I missing?
--
TK ~ aka Terry Kimpling
http://wejuggle2.com/circusskills.php learn/make juggle/balance equipment
It ain't what they call you, it's what you answer to. W. C. Fields
Agree. It is much simpler for the developer to use filter and sanitize.
The reason you found it 'late' is simply due to the fact that it was
added only recently to the PHP core.
Before PHP 5.2 you needed to use PECL for the functionality.
This is what php.net says:
http://nl.php.net/manual/en/filter.installation.php
======================================================
Installation
The filter extension is enabled by default as of PHP 5.2.0. Before this
time an experimental PECL extension was used, however, the PECL version
is no longer recommended or updated.
======================================================
Regards,
Erwin Moller
--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare