Message from discussion
email_validering
Received: by 10.68.236.198 with SMTP id uw6mr6907167pbc.3.1334490032148;
Sun, 15 Apr 2012 04:40:32 -0700 (PDT)
Path: r9ni58868pbh.0!nntp.google.com!news1.google.com!postnews.google.com!2g2000yqp.googlegroups.com!not-for-mail
From: Hans Lommeuld <hanslomme...@gmail.com>
Newsgroups: dk.edb.internet.webdesign.serverside.php
Subject: email_validering
Date: Sun, 15 Apr 2012 04:40:31 -0700 (PDT)
Organization: http://groups.google.com
Lines: 78
Message-ID: <46792c09-079d-4029-bcfe-d6b101c57b07@2g2000yqp.googlegroups.com>
NNTP-Posting-Host: 2.104.252.223
Mime-Version: 1.0
X-Trace: posting.google.com 1334490032 4265 127.0.0.1 (15 Apr 2012 11:40:32 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 15 Apr 2012 11:40:32 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: 2g2000yqp.googlegroups.com; posting-host=2.104.252.223; posting-account=qsWZDQoAAADE_XBI8oiwhIlLMdyDVouL
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0,gzip(gfe)
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hvad mangler jeg for at f=E5 valideringen til at virke?
Skal jeg anvende noget header(Location) i tilf=E6lde af invalid email!?
I s=E5 fald hvor?
Hilsen
Claus
Alias: "Hans Lommeuld"
$email=3D$_POST['email'];
if (isset($email)){
function validEmail($email)
{
$isValid =3D true;
$atIndex =3D strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
{
$isValid =3D false;
}
else
{
$domain =3D substr($email, $atIndex+1);
$local =3D substr($email, 0, $atIndex);
$localLen =3D strlen($local);
$domainLen =3D strlen($domain);
if ($localLen < 1 || $localLen > 64)
{
// local part length exceeded
$isValid =3D false;
}
else if ($domainLen < 1 || $domainLen > 255)
{
// domain part length exceeded
$isValid =3D false;
}
else if ($local[0] =3D=3D '.' || $local[$localLen-1] =3D=3D '.')
{
// local part starts or ends with '.'
$isValid =3D false;
}
else if (preg_match('/\\.\\./', $local))
{
// local part has two consecutive dots
$isValid =3D false;
}
else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
{
// character not valid in domain part
$isValid =3D false;
}
else if (preg_match('/\\.\\./', $domain))
{
// domain part has two consecutive dots
$isValid =3D false;
}
else if
(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=3D\\/$\'*+?^{}|~.-])+$/',
str_replace("\\\\","",$local)))
{
// character not valid in local part unless
// local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/',
str_replace("\\\\","",$local)))
{
$isValid =3D false;
}
}
if ($isValid && !(checkdnsrr($domain,"MX") ||
checkdnsrr($domain,"A")))
{
// domain not found in DNS
$isValid =3D false;
}
}
return $isValid;
}
}