24 lines
540 B
PHP
24 lines
540 B
PHP
|
<?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("DELETE FROM likes WHERE user_id = :user_id AND post_id = :post_id");
|
||
|
$like_abfrage->execute([':user_id' => $like_id, ':post_id' => $liked_id]);
|
||
|
header("location: ../index.php");
|
||
|
}
|
||
|
catch(PDOException $e){
|
||
|
echo $e->getMessage();
|
||
|
}
|
||
|
|
||
|
|