make($_POST,[ 'name' => 'required', 'email' => 'required|email', 'year' => 'required|numeric', 'birthday' => 'required|date', 'vocation' => 'required', 'privacy' => 'required' ]); $validation->setMessages([ 'required' => ":attribute muss ausgefüllt werden", 'email' => "Die E-Mail Adresse :email ist nicht gültig", 'numeric' => ":numeric muss eine Zahl sein", 'date' => ":attribute muss ein Datum sein" ]); $validation->validate(); if($validation->fails()) { $errors = $validation->errors(); echo "
";
    print_r($errors->firstOfAll());
    echo "
"; exit; } $validData = $validation->getValidData(); $config = getConfig(); $validData['verify'] = 0; unset($validData['privacy']); $db = getDatabase(); $statement = $db->prepare("INSERT INTO entries(name, mail, year, birthday, verify, vocation) VALUES (:name, :email, :year, :birthday, :verify, :vocation)"); if(!$statement->execute($validData)) { echo "Datenbank Fehler"; exit; } $id = $db->lastInsertId(); $statement = $db->prepare("INSERT INTO verify(id) VALUES (:id)"); if(!$statement->execute(['id' => $id])) { echo "Datenbank Fehler"; exit; } $statement = $db->prepare("SELECT uuid from verify WHERE id = :id"); if(!$statement->execute(['id' => $id])) { echo "database Error"; } $uuid = $statement->fetch(PDO::FETCH_ASSOC)['uuid']; $mail = new PHPMailer(true); $mail->isSMTP(); $mail->SMTPAuth = true; $mail->Host = $config['mail_server']; $mail->Port = $config['mail_port']; $mail->Username = $config['mail_user']; $mail->Password = $config['mail_password']; $mail->From = $config['mail_address']; $mail->FromName = $config['mail_name']; try { $mail->addAddress($validData['email'], $validData['name']); } catch (\PHPMailer\PHPMailer\Exception $e) { echo $e->getMessage(); } $mail->Subject = 'Bestätigung einer Eintragung'; $mail->AltBody = 'Bitte bestätige deine Eintragung unter folgendem Link: ' . $config['url'] . "/verify.php/?id=" . $uuid; $mail->Body = 'Bitte bestätige deine Eintragung bitte hier'; try { !$mail->send(); } catch (\PHPMailer\PHPMailer\Exception $e) { echo $e; } returnHeader(); ?> Vielen Dank, bitte bestätige deine E-Mail Adresse