71 lines
2.3 KiB
PHP
71 lines
2.3 KiB
PHP
<?php
|
|
session_start();
|
|
/*
|
|
// Überprüfen, ob der Patient authentifiziert ist
|
|
if (!isset($_SESSION['patient_id'])) {
|
|
header("Location: umfrage.php");
|
|
exit;
|
|
}
|
|
*/
|
|
|
|
|
|
$question_1 = $_POST['question_1'];
|
|
$question_2 = $_POST['question_2'];
|
|
$question_3 = $_POST['question_3'];
|
|
$question_4 = $_POST['question_4'];
|
|
$question_5 = $_POST['question_5'];
|
|
$question_6 = $_POST['question_6'];
|
|
$question_7 = $_POST['question_7'];
|
|
$question_8 = $_POST['question_8'];
|
|
$question_9 = $_POST['question_9'];
|
|
$question_10 = $_POST['question_10'];
|
|
$message = $_POST['message'];
|
|
|
|
include("inc/config.inc.php");
|
|
if ($con->connect_error) {
|
|
die("Verbindung fehlgeschlagen: " . $con->connect_error);
|
|
}
|
|
// Umfrageantworten speichern
|
|
// Vorbereiten der SQL-Anfrage
|
|
$stmt = $con->prepare("INSERT INTO survey_responses
|
|
(question_1, question_2, question_3, question_4, question_5, question_6, question_7, question_8, question_9, question_10, message)
|
|
VALUES
|
|
('". $question_1 . "', '". $question_2 . "', '". $question_3 . "', '". $question_4 . "', '". $question_5 . "', '". $question_6 . "', '". $question_7 . "', '". $question_8 . "', '". $question_9 . "', '". $question_10 . "', '". $message . "');");
|
|
if ($stmt === false) {
|
|
die('Fehler bei der Vorbereitung der SQL-Abfrage: ' . $con->error);
|
|
}
|
|
// Bindung der Parameter
|
|
#$stmt->bind_param("ssssssssss", $question_1, $question_2, $question_3, $question_4, $question_5, $question_6, $question_7, $question_8, $question_9, $question_10);
|
|
|
|
// Ausführen der SQL-Anfrage
|
|
if (!$stmt->execute()) {
|
|
die('Fehler bei der Ausführung der SQL-Abfrage: ' . $stmt->error);
|
|
}
|
|
|
|
|
|
|
|
// Letzte Umfrage-Teilnahme aktualisieren
|
|
$stmt = $con->prepare("UPDATE survey_patients SET survey_last_taken = NOW() WHERE id = ?");
|
|
$stmt->bind_param("i", $_SESSION['patient_id']);
|
|
$stmt->execute();
|
|
|
|
|
|
// Lösche alle Session-Variablen
|
|
session_unset();
|
|
|
|
// Zerstöre die Session
|
|
session_destroy();
|
|
|
|
// Lösche das Session-Cookie, wenn du es auch am Client löschen möchtest
|
|
if (ini_get("session.use_cookies")) {
|
|
$params = session_get_cookie_params();
|
|
setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
|
|
}
|
|
|
|
// Weiterleitung auf eine andere Seite (optional)
|
|
header("Location: umfrage_danke.php");
|
|
exit();
|
|
?>
|
|
|
|
?>
|