<?php
// V0201201203 @session_start();
// Beginn Funktion ‘DEAlter’ function DEAlter($GebDEDatum) {
$DEDatumsFormat = '/^[0-3][0-9]\.[0-1][0-9]\.[1-2][0-9][0-9][0-9]$/';
if (preg_match($DEDatumsFormat, $GebDEDatum)) { $AktuellesDEDatum = date("j.n.Y"); $AktuellesDEDatumArray = explode('.', $AktuellesDEDatum); $AktuellesDEDatumArrayalsInt = array_map('intval', $AktuellesDEDatumArray);
$AktuellerTag = $AktuellesDEDatumArrayalsInt[0]; $AktuellersMonat = $AktuellesDEDatumArrayalsInt[1]; $AktuellesJahr = $AktuellesDEDatumArrayalsInt[2];
$GebDEDatumArray = explode(".", $GebDEDatum); $GebDEDatumArrayalsInt = array_map('intval', $GebDEDatumArray);
$GebTag = $GebDEDatumArrayalsInt[0]; $GebMonat = $GebDEDatumArrayalsInt[1]; $GebJahr = $GebDEDatumArrayalsInt[2];
if(checkdate($GebMonat, $GebTag, $GebJahr)) { $AlterinJahren = $AktuellesJahr - $GebJahr;
if ($AktuellersMonat > $GebMonat) { return $AlterinJahren; }
if (($AktuellersMonat == $GebMonat) && ($AktuellerTag >= $GebTag)) { return $AlterinJahren; } return ($AlterinJahren-1); } }
return (-1);
} // Ende Funktion ‘DEAlter’
// Beginn Überprüfung des Alters if (isset($_POST['action']) && ($_POST['action'] == 'send') && isset($_POST['Geburtstag'])) {
$WieAlt = DEAlter($_POST['Geburtstag']); $_SESSION['Eingabename']=htmlentities($_POST['Name'],ENT_QUOTES); $_SESSION['Eingabedatum']=htmlentities($_POST['Geburtstag'],ENT_QUOTES);
// Datums-Format falsch eingetragen if ($WieAlt <= -1) { $_SESSION['Datumformat']="falsch"; } else { $_SESSION['Datumformat']="richtig"; }
// Alter prüfen, hier ob bereits 18 Jahre alt if ($WieAlt >= 18) { $_SESSION['erwachsen']="JA"; } else { if ($WieAlt >= 0) { $_SESSION['erwachsen']="NEIN"; } }
} // Ende Überprüfung des Alters
?>
|