FVS-Social-Projekt-Neu/FVS-Social/like/like.php

24 lines
539 B
PHP
Raw Normal View History

<?php
session_start();
include "../db_connect.php";
if(!isset($_SESSION['user_id']) || !isset($_POST['post_id'])){
header("location: ../index.php");
}
$like_id = $_SESSION['user_id'];
$liked_id = $_POST['post_id'];
$username = $_POST['username'];
try {
$like_abfrage = $pdo->prepare("INSERT INTO likes (user_id, post_id) VALUES (:user_id, :post_id)");
$like_abfrage->execute([':user_id' => $like_id, ':post_id' => $liked_id]);
header("location: ../index.php");
}
catch(PDOException $e){
echo $e->getMessage();
}