Zeltlager/Sicherung_Zeltlageranmeldung/step2.php

94 lines
3.2 KiB
PHP

<?php
require_once($_SERVER['DOCUMENT_ROOT'].'jformer.php');
require_once($_SERVER['DOCUMENT_ROOT'].'db.php');
session_start();
if ( (!isset($_SESSION['uid'])) || ($_SESSION['uid'] == "") )
{
error_log("ERROR: STEP 2 wurde mit folgender UID aufgerufen:>".$_SESSION['uid']."<");
header('Location: index.php');
}
$uid = $_SESSION['uid'];
$mydb = new DB_MySQL();
//$mydb->query("SELECT * AnmeldungAdressen WHERE uid='$uid'");
$mydb->query("SELECT * FROM `AnmeldungAdressen` WHERE `uid` = '$uid' ");
$row = $mydb->fetchRow();
$Strasse = $row['strasse'];
$Plz = $row['plz'];
$Ort = $row['wohnort'];
$Telefon = $row['telefon'];
$mydb->disconnect();
$AnschriftVonLagerteilnehmer = $Strasse . " " . $Plz . " " . $Ort;
$Form = new JFormer('AdressForm', array('submitButtonText' => '-> Anmeldung Step 3'));
$Form->addJFormComponentArray(array(
new JFormComponentHtml('<p><b>Kontaktperson, die w&auml;hrend des Lagers zu erreichen ist:</b></p>'),
new JFormComponentName('namekontaktperson', 'Name der Kontaktperson:', array(
'validationOptions' => array('required'),
'middleInitialHidden' => true
)),
new JFormComponentAddress('anschriftkontakt', 'Anschrift der Kontaktperson:', array(
'validationOptions' => array('required'),
'initialValues' => array('addressLine1' => $Strasse , 'city' => $Ort , 'zip' => $Plz),
'addressLine2Hidden' => true,
)),
new JFormComponentSingleLineText('telefonkontakt', 'Telefonnummer der Kontaktperson:', array(
'width' => 'long',
'initialValue' => $Telefon,
'validationOptions' => array('required'),
)),
));
function onSubmit($formValues)
{
session_start();
$uid = $_SESSION['uid'];
$nachname = $formValues->namekontaktperson->lastName;
$vorname = $formValues->namekontaktperson->firstName;
$strasse = $formValues->anschriftkontakt->addressLine1;
$plz = $formValues->anschriftkontakt->zip;
$wohnort = $formValues->anschriftkontakt->city;
$telefon = $formValues->telefonkontakt;
if ($uid == "")
{
error_log("ERROR: SUBMIT bei STEP 2 wurde ohne UID aufgerufen");
$_SESSION['step'] = "0";
}
else
{
$_SESSION['step'] = "3";
//DB-Eintrag
$mydb = new DB_MySQL();
$mydb->query("UPDATE AnmeldungStatus SET step = '2' WHERE uid='$uid' AND step < '10' ");
$mydb->query("INSERT INTO AnmeldungNotfallkontakt (uid, notfall_nachname, notfall_vorname, notfall_strasse, notfall_plz, notfall_wohnort, notfall_telefon) VALUES ('$uid', '$nachname', '$vorname', '$strasse', '$plz', '$wohnort' , '$telefon') ON DUPLICATE KEY UPDATE notfall_nachname = '$nachname', notfall_vorname = '$vorname', notfall_strasse = '$strasse', notfall_plz = '$plz', notfall_wohnort = '$wohnort', notfall_telefon = '$telefon' ");
$mydb->disconnect();
}
$response = array('redirect' => 'index.php');
return $response;
}
// Process any request to the form
$Form->processRequest();
?>