VERO/deleteUser.php
2026-03-04 10:12:09 +01:00

111 lines
2.7 KiB
PHP

<?php
// Include config file
require_once "config.php";
$config = parse_ini_file("config.ini", true) ;
// Include config file
$config = parse_ini_file("config.ini", true) ;
$baseURL = $config['base']['URL'];
// Initialize the session
session_start();
// User not loggied in
if ($_SESSION["loggedin"] === false) {
$deletion_err = "Sie sind nicht angemeldet. Ein Löschung ist daher nicht möglich.";
} else {
$deletion_err = '';
}
$email = $_SESSION["email"];
if(empty($deletion_err) ){
// Prepare a select statement
$sql = "DELETE FROM User WHERE userEmail = ?";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "s", $param_email);
// Set parameters
$param_email = $email;
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt) === false){
$deletion_err = "Benutzerkonto wurde nicht gelöscht. Wenden Sie sich an den Administrator ;-) !";
} else {
// Close statement
// Initialize the session
session_start();
// Unset all of the session variables
$_SESSION = array();
// Destroy the session.
session_destroy();
session_unset();
session_regenerate_id(true);
}
mysqli_stmt_close($stmt);
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Login</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
<link href="css/bibb.css" media="all" rel="stylesheet" type="text/css">
<style>
html, body {
height: 100%;
}
.stickywrapper {
min-height: 60vh;
display: flex;
flex-direction: column;
}
.content {
flex: 1;
}
</style>
</head>
<body>
<?php include "templates/headerLogin.php"; ?>
<div class="stickywrapper">
<!-- Hauptinhalt der Seite -->
<div class="content">
<div class="container my-5">
<div id="verifcationScreen" class="wrapperconfirmation pb-3 shadow p-3 ml-10 bg-body rounded align-items-center bg-box">
<h4>Benutzerlöschung</h4>
<?php
echo '<div class="row">';
if ($deletion_err == '') {
echo "Benutzermit der E-Mail-Adresse " .$email ." wurde gelöscht" ;
} else {
echo $deletion_err;
}
echo ' </div>' ;
?>
</div>
</div>
</div>
</div>
<?php include "templates/stickyfooter.php" ?>
</body>
</html>