FVS-Social-Projekt-Neu/FVS-Social/upload-profile/delete-pb.php

27 lines
571 B
PHP
Raw Permalink Normal View History

<?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;
?>