<?php
class EmailAddressValidator
{
function check_email_address($strEmailAddress)
{
if (get_magic_quotes_gpc())
{
$strEmailAddress = stripslashes($strEmailAddress);
}
if (preg_match('/[\x00-\x1F\x7F-\xFF]/', $strEmailAddress))
{
return false;
}
if (!$this->check_text_length($strEmailAddress, 3, 256))
{
return false;
}
$intAtSymbol = strrpos($strEmailAddress, '@');
if ($intAtSymbol === false)
{
return false;
}
$arrEmailAddress[0] = substr($strEmailAddress, 0, $intAtSymbol);
$arrEmailAddress[1] = substr($strEmailAddress, $intAtSymbol + 1);
$arrTempAddress[0] = preg_replace('/./','',$arrEmailAddress[0]);
$arrTempAddress[0] = preg_replace('/"[^"]+"/','',$arrTempAddress[0]);
$arrTempAddress[1] = $arrEmailAddress[1];
$strTempAddress = $arrTempAddress[0] . $arrTempAddress[1];
if (strrpos($strTempAddress, '@') !== false)
{
return false;
}
if (!$this->check_local_portion($arrEmailAddress[0]))
{
return false;
}
if (!$this->check_domain_portion($arrEmailAddress[1]))
{
return false;
}
return true;
}
function check_local_portion($strLocalPortion)
{
if (!$this->check_text_length($strLocalPortion, 1, 64))
{
return false;
}
$arrLocalPortion = explode('.', $strLocalPortion);
for ($i = 0, $max = sizeof($arrLocalPortion); $i < $max; $i++)
{
if (!preg\_match('.^('. '([A-Za-z0-9!#$%&\'\*+/=?^\_`{|}~-]'
. '[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]{0,63})'
.'|'
. '("[^\"]{0,62}")'
.')$.'
,$arrLocalPortion[$i]))
{
return false;
}
}
return true;
}
function check_domain_portion($strDomainPortion)
{
if (!$this->check_text_length($strDomainPortion, 1, 255))
{
return false;
}
if (preg_match('/^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])'
.'(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}$/'
,$strDomainPortion) ||
preg_match('/^[(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])'
.'(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}]$/'
,$strDomainPortion)) {
return true;
}
else
{
$arrDomainPortion = explode('.', $strDomainPortion);
if (sizeof($arrDomainPortion) < 2)
{
return false;
}
for ($i = 0, $max = sizeof($arrDomainPortion); $i < $max; $i++)
{
if (!$this->check_text_length($arrDomainPortion[$i], 1, 63))
{
return false;
}
if (!preg_match('/^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|'
.'([A-Za-z0-9]+))$/', $arrDomainPortion[$i]))
{
return false;
}
if ($i == $max - 1)
{
if (strlen(preg_replace('/[0-9]/', '', $arrDomainPortion[$i])) <= 0)
{
return false;
}
}
}
}
return true;
}
function check_text_length($strText, $intMinimum, $intMaximum)
{
$intTextLength = strlen($strText);
if (($intTextLength < $intMinimum) || ($intTextLength > $intMaximum))
{
return false;
} else {
return true;
}
}
}
$bln_Error = FALSE;
$str_Preg = "";
$str_Mail_To = "HIER MEINE MAIL ADRESSE DRIN";
$str_Mail_From = "AUSGABE ABSENDER zu meinem OUTLOOK";
$str_Mail_Subject = "";
$str_Mail_Content = "";
$str_Mail_Header = "From: ".$str_Mail_From."\r\n";
$str_Mail_Header .= "To: ".$str_Mail_To."\r\n";
$str_Mail_Header .= "MIME-Version: 1.0\r\n";
$str_Mail_Header .= "Content-Type: text/plain; charset="ISO-8859-1"\r\n";
$str_Mail_Header .= "Content-Transfer-Encoding: quoted-printable\r\n";
$str_Name = isset($_POST['name']) ? $_POST['name'] : "";
$bln_Name_Empty = FALSE;
$bln_Name_Error = FALSE;
$str_Vorname = isset($_POST['vorname']) ? $_POST['vorname'] : "";
$bln_Vorname_Empty = FALSE;
$bln_Vorname_Error = FALSE;
$str_Telefonnummer = isset($_POST['telefonnummer']) ? $_POST['telefonnummer'] : "";
$bln_Telefonnummer_Empty = FALSE;
$bln_Telefonnummer_Error = FALSE;
$str_Email = isset($_POST['e-mail']) ? $_POST['e-mail'] : "";
$bln_Email_Empty = FALSE;
$bln_Email_Error = FALSE;
$bln_Workshop_Empty = FALSE;
$bln_Level_Empty = FALSE;
$str_Nachricht = isset($_POST['nachricht']) ? $_POST['nachricht'] : "";
if (isset($_POST['sent']))
{
$str_Mail_Content = "Neue Anmeldung auf www.sensnes-dance.com:\n\n";
if (empty($_POST['name']))
{
$bln_Name_Empty = TRUE;
$bln_Error = TRUE;
}
else
{
$str_Preg = "^([a-z]|[A-Z]|á|é|í|ó|ú|Á|É|Í|Ó|Ú|à|è|ì|ò|ù|À|È|Ì|Ò|Ù| )*$";
if (strlen(trim($_POST['name'])) >= 2 and preg_match("/$str_Preg/", trim($_POST['name'])))
{
$str_Mail_Content .= "Name: " . $_POST['name'] . "\n";
}
else
{
$bln_Name_Error = TRUE;
$bln_Error = TRUE;
}
}
if (empty($_POST['vorname']))
{
$bln_Vorname_Empty = TRUE;
$bln_Error = TRUE;
}
else
{
$str_Preg = "^([a-z]|[A-Z]|á|é|í|ó|ú|Á|É|Í|Ó|Ú|à|è|ì|ò|ù|À|È|Ì|Ò|Ù| )*$";
if (strlen(trim($_POST['vorname'])) >= 2 and preg_match("/$str_Preg/", trim($_POST['vorname'])))
{
$str_Mail_Content .= "Vorname: " . $_POST['vorname'] . "\n";
}
else
{
$bln_Vorname_Error = TRUE;
$bln_Error = TRUE;
}
}
if (empty($_POST['telefonnummer']))
{
$bln_Telefonnummer_Empty = TRUE;
$bln_Error = TRUE;
}
else
{
$str_Preg = "[a-zA-Z]";
if (preg_match("/$str_Preg/", trim($_POST['telefonnummer'])))
{
$bln_Telefonnummer_Error = TRUE;
$bln_Error = TRUE;
}
else
{
$str_Mail_Content .= "Telefonnummer: " . $_POST['telefonnummer'] . "\n";
}
}
if (empty($_POST['e-mail']))
{
$bln_Email_Empty = TRUE;
$bln_Error = TRUE;
}
else
{
$validator = new EmailAddressValidator;
if ($validator->check_email_address($_POST['e-mail']))
{
$str_Mail_Content .= "E-mail: " . $_POST['e-mail'] . "\n";
}
else
{
$bln_Email_Error = TRUE;
$bln_Error = TRUE;
}
}
if ($_POST['workshop']=="Bitte wählen Sie aus!")
{
$bln_Workshop_Empty = TRUE;
$bln_Error = TRUE;
}
else
{
$str_Mail_Content .= "Workshop: " . $_POST['workshop'] . "\n";
}
if ($_POST['level']=="Bitte wählen Sie aus!")
{
$bln_Level_Empty = TRUE;
$bln_Error = TRUE;
}
else
{
$str_Mail_Content .= "Level: " . $_POST['level'] . "\n";
}
if (!empty($_POST['nachricht']))
{
$str_Mail_Content .= "\nNachricht: " . $_POST['nachricht'] . "\n\n";
}
if (isset($_POST['checkbox']))
{
$str_Mail_Content .= "Newsletter abonieren: JA\n";
}
else
{
$str_Mail_Content .= "Newsletter abonieren: NEIN\n";
}
if ($bln_Error == FALSE)
{
$str_Mail_Content .= "\n" . "Visitor IP: " . $_SERVER["HTTP_X_REMOTECLIENT_IP"];
$str_Mail_Subject = "Anmeldung fuer " . $_POST['workshop'] . " " . $_POST['level'];
if (mail($str_Mail_To, $str_Mail_Subject, $str_Mail_Content, $str_Mail_Header))
{
echo "<p align="center" class="style16 style5">Danke für Deine Anmeldung. Wir freuen uns Dich bei uns in den Workshops begrüßen zu dürfen! Nach Deiner Anmeldung erhälst Du binnen eines Tages eine Bestätigungsmail, mit welcher Dein Workshopplatz gesichert ist.</p>";
}
else
{
echo "<p align="center" class="style16 style5">Aufgrund eines technischen Problems, konnte Deine Anmeldung leider nicht registriert werden...</p>";
}
}
}
if (isset($_POST['sent']) and $bln_Error == FALSE)
{
}
else
{
?>
!!!!!HIER FÄNGT DANN DAS FORMULAR AN !!!!
!!!!!HIER HÖRT ES DANN AUF!!!!!
<?php
} /* end if*/
?>
so das mal das gesamte mit allem drum und dran^^
Formular poste ich gleich danach da das ganze zu lange ist sonst :)
bin gespannt :)