FVS-Social-Projekt-Neu/FVS-Social/follow/unfollow.php
erik 55abbf6cb3 Version 0.8
-Folgen und Nicht mehr Folgen verfügbar
-Kleine Verbsesserungen

Signed-off-by: erik <micheler@steinbeis.schule>
2025-02-26 08:56:42 +01:00

24 lines
No EOL
666 B
PHP

<?php
session_start();
include "../db_connect.php";
if (!isset($_SESSION['user_id']) || !isset($_POST['following_id'])) {
header("location: ../index.php");
}
$follower_id = $_SESSION['user_id'];
$following_id = $_POST['following_id'];
$username = $_POST['username'];
if ($following_id == $follower_id) {
die("Geht nicht Amk");
}
try {
$stmt = $pdo->prepare("DELETE FROM followers WHERE following_id = :following_id AND follower_id = :follower_id");
$stmt->execute(['follower_id' => $follower_id, 'following_id' => $following_id]);
header("location: ../profile.php?user=" . $username);
} catch (PDOException $e) {
echo $e->getMessage();
}