FVS-Social-Projekt-Neu/FVS-Social/upload-profile/delete-pb.php
erik 005c33dae9 Version 0.6
- Uploaden von Posts möglich
- Kleine verbesserung vorgenommen

Signed-off-by: erik <micheler@steinbeis.schule>
2025-02-12 20:13:29 +01:00

27 lines
No EOL
571 B
PHP

<?php
session_start();
include "../db_connect.php";
$userId = $_SESSION['user_id'];
$stmt = $pdo->prepare("SELECT file_path FROM profile_pictures WHERE user_id = :id");
$stmt->execute([':id' => $userId]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if($user && !empty($user['file_path'])){
$file_Path = "../" . $user['file_path'];
if(file_exists($file_Path)){
unlink($file_Path);
}
$stmt = $pdo->prepare("DELETE FROM profile_pictures WHERE user_id = :id");
$stmt->execute([':id' => $userId]);
}
header("Location: ../index.php");
exit;
?>