Hi,
I have checked out the FAQ area and found a huge script for email validation but unfortunately it's a bit complex for me right now and I only need something simple.
All I want to have is a script that will check to make sure that there are no spaces or weird characters that aren't allowed in email syntax, only one @-sign, a top level domain and make sure that the format follows this:
[text and/or #] one @-sign [text and/or #] .top level domain
I came across a script and have been playing around with it but it doesn't quite work to the extent that I need it to. Can someone please help me out?
[-----SCRIPT-----]
<?php
$evalid=2;
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $email))
{
$evalid=1;
}
else
{
$evalid=2;
}
##### Below part will appear much later in my script #####
if ($evalid=='1')
{
echo "VALID EMAIL\n";
}
else
{
echo "INVALID EMAIL\n";
}
?>
[-----SCRIPT-----]
The script recognizes the format (sort of) but it allows spaces and 2 @ signs and says that 1@2. is valid, but clearly it is not.
Thanks for any help!
I have checked out the FAQ area and found a huge script for email validation but unfortunately it's a bit complex for me right now and I only need something simple.
All I want to have is a script that will check to make sure that there are no spaces or weird characters that aren't allowed in email syntax, only one @-sign, a top level domain and make sure that the format follows this:
[text and/or #] one @-sign [text and/or #] .top level domain
I came across a script and have been playing around with it but it doesn't quite work to the extent that I need it to. Can someone please help me out?
[-----SCRIPT-----]
<?php
$evalid=2;
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $email))
{
$evalid=1;
}
else
{
$evalid=2;
}
##### Below part will appear much later in my script #####
if ($evalid=='1')
{
echo "VALID EMAIL\n";
}
else
{
echo "INVALID EMAIL\n";
}
?>
[-----SCRIPT-----]
The script recognizes the format (sort of) but it allows spaces and 2 @ signs and says that 1@2. is valid, but clearly it is not.
Thanks for any help!
