FVS-Social-Projekt-Neu/FVS-Social/follow/follow.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

25 lines
659 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("INSERT INTO followers (follower_id, following_id) VALUES (:follower_id, :following_id)");
$stmt->execute(['follower_id' => $follower_id, 'following_id' => $following_id]);
header("location: ../profile.php?user=".$username);
}
catch(PDOException $e){
echo $e->getMessage();
}