Version 0.8
-Folgen und Nicht mehr Folgen verfügbar -Kleine Verbsesserungen Signed-off-by: erik <micheler@steinbeis.schule>
This commit is contained in:
parent
1d79822346
commit
55abbf6cb3
6 changed files with 76 additions and 12 deletions
|
@ -6,7 +6,6 @@ $user_id = $_SESSION['user_id'];
|
|||
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
echo "Server Method funktioniert";
|
||||
$username = $_POST['username'];
|
||||
|
||||
$stmt = $pdo->prepare("UPDATE users SET username = :username WHERE id = :user_id");
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Erfolg</h1>
|
||||
</body>
|
||||
</html>
|
25
FVS-Social/follow/follow.php
Normal file
25
FVS-Social/follow/follow.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?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();
|
||||
}
|
||||
|
24
FVS-Social/follow/unfollow.php
Normal file
24
FVS-Social/follow/unfollow.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?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();
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 44 KiB |
|
@ -57,6 +57,10 @@ try {
|
|||
$selected_profile_image1 = 'profile-pics/default.jpeg';
|
||||
}
|
||||
|
||||
$stmt3 = $pdo->prepare("SELECT COUNT(following_id) AS following_count FROM followers WHERE following_id = :user_id ");
|
||||
$stmt3->execute([':user_id' => $selected_user['id']]);
|
||||
$follower_count = $stmt3->fetch(PDO::FETCH_ASSOC)['following_count'];
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die("Fehler: " . $e->getMessage());
|
||||
}
|
||||
|
@ -106,6 +110,28 @@ try {
|
|||
<img src="<?php echo htmlspecialchars($selected_profile_image); ?>" alt="Profilbild" width="100">
|
||||
<p>Email: <?php echo htmlspecialchars($selected_user['email']); ?></p>
|
||||
<p>Registriert seit: <?php echo htmlspecialchars($selected_user['created_at']); ?></p>
|
||||
<h3>Follower: <?php echo htmlspecialchars($follower_count) ?></h3>
|
||||
<?php
|
||||
$follower_id = $_SESSION['user_id'];
|
||||
|
||||
$stmt7 = $pdo->prepare("SELECT follower_id, following_id FROM followers WHERE follower_id = :user_id AND following_id = :id");
|
||||
$stmt7->execute([':user_id' => $follower_id, ':id' => $selected_user['id']]);
|
||||
$isfollower = $stmt7->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
<?php if(!$isfollower):?>
|
||||
<form action="follow/follow.php" method="post">
|
||||
<input type="hidden" name="following_id" value="<?= htmlspecialchars($selected_user['id']) ?>">
|
||||
<input type="hidden" name="username" value="<?= htmlspecialchars($selected_user['username']) ?>">
|
||||
<button type="submit">Folgen</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<form action="follow/unfollow.php" method="post">
|
||||
<input type="hidden" name="following_id" value="<?= htmlspecialchars($selected_user['id']) ?>">
|
||||
<input type="hidden" name="username" value="<?= htmlspecialchars($selected_user['username']) ?>">
|
||||
<button type="submit">Nicht mehr Folgen</button>
|
||||
</form>
|
||||
<?php endif;?>
|
||||
<a href="index.php">Zurück zur Startseite</a>
|
||||
</div>
|
||||
|
||||
|
@ -131,6 +157,7 @@ try {
|
|||
<img class="post-pics" src="<?php echo htmlspecialchars($post['image_path']); ?>" alt="Bild zum Post">
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<p><small>Erstellt am: <?php echo $post['created_at']; ?></small></p>
|
||||
<?php if ($userId == $post['user_id']): ?>
|
||||
<form action="upload-post/delete-post.php" method="post">
|
||||
|
|
Loading…
Add table
Reference in a new issue