format('Y-m-d'); $querystr = "SELECT * FROM li_registrations WHERE li_registrations.rid = ${rid}"; $result = mysqli_query($connection, $querystr); if($result->num_rows !== 0) { $querystr = "UPDATE li_registrations SET firstname='${firstname}', lastname='${lastname}', birthday='${birthday}', gender=${gender}, street='${street}', house=${house}, zip='${zip}', city='${city}', phone='${phone}', email='${email}', accountholder='${accountHolder}', iban='${iban}', bic='${bic}', bank='${bank}', contracttype=${contracttype}, applicationconsent=${applicationconsent}, datachangeconsent=${datachangeconsent}, privacypolicyconsent=${privacypolicyconsent}, directdebitconsent=${directdebitconsent}, returndebitconsent=${returndebitconsent}, datastorageconsent=${datastorageconsent}, multimediaconsent=${multimediaconsent}, WHERE rid=${rid}"; } else { $querystr = "INSERT INTO li_registrations (firstname, lastname, birthday, gender, street, house, zip, city, phone, email, accountholder, iban, bic, bank, contracttype, applicationconsent, datachangeconsent, privacypolicyconsent, directdebitconsent, returndebitconsent, datastorageconsent, multimediaconsent, registrationfrom) VALUES('{$firstname}', '{$lastname}', '{$birthday}', {$gender}, '{$street}', {$house}, '{$zip}', '{$city}', '{$phone}', '{$email}', '{$accountholder}', '{$iban}', '{$bic}', '{$bank}', ${contracttype}, {$applicationconsent}, {$datachangeconsent}, {$privacypolicyconsent}, {$directdebitconsent}, {$returndebitconsent}, {$datastorageconsent}, {$multimediaconsent}, '{$registrationfrom}')"; } $result = mysqli_query($connection, $querystr); $currentDate = new DateTime(); $formattedRegistrationFrom = new DateTime($registrationfrom); $formattedBirthday = new DateTime($birthday); $data = (object) [ 'firstname' => $firstname, 'lastname' => $lastname, 'birthdate' => $formattedBirthday->format('d.m.Y'), 'gender' => gender($gender), 'street' => $street, 'house' => $house, 'zip' => $zip, 'city' => $city, 'phone' => $phone, 'email' => $email, 'accountholder' => $accountholder, 'iban' => $iban, 'bic' => $bic, 'bank' => $bank, 'contracttype' => $contracttype, 'registrationFrom' => $formattedRegistrationFrom->format('d.m.Y'), 'rate' => getRegistrationPrice($birthday, $contracttype) . ',00' . chr(128), 'pdfname' => "{$currentDate->format('Y-m-d')}-lidance-registrierung.pdf", 'pdfcontent' => '' ]; $data->pdfcontent = getRegistrationPdf($data); sendRegistrationMail($data); sendConfirmationMail($data); } catch (Exception $e) { $result = $e; } echo json_encode('{ "result": "' . $result . '" }'); ?>