Version 0.6

- Uploaden von Posts möglich
- Kleine verbesserung vorgenommen

Signed-off-by: erik <micheler@steinbeis.schule>
This commit is contained in:
Erik M 2025-02-12 20:13:29 +01:00
parent 35b043178a
commit 005c33dae9
23 changed files with 976 additions and 0 deletions

13
FVS-Social/db_connect.php Normal file
View file

@ -0,0 +1,13 @@
<?php
$host = '134.255.227.143';
$db = 'socialnetwork';
$user = 'socialuser';
$pass = '1234';
try {
$pdo = new PDO("mysql:host=$host;dbname=$db;charset=utf8mb4", $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
die("Fehler bei der Verbindung zur Datenbank: " . $e->getMessage());
}
?>

11
FVS-Social/erfolg.html Normal file
View file

@ -0,0 +1,11 @@
<!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>

BIN
FVS-Social/img/Logomark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

190
FVS-Social/index.php Normal file
View file

@ -0,0 +1,190 @@
<?php
session_start();
$page = isset($_GET['page']) ? $_GET['page'] : 'posts';
if(!isset($_SESSION['user_id'])) {
die("<p>Du musst dich zuerst Einloggen oder Regestrieren <br> <a href='login/login-page.html'>Hier Einloggen</a> <br> <a href='signup/signup-page.html'>Hier Regestrieren</a>");
}
include 'db_connect.php';
try {
$userId = $_SESSION['user_id'];
$stmt1 = $pdo->prepare("SELECT username, email, created_at FROM users WHERE id = :id");
$stmt1->execute([':id' => $userId]);
$user = $stmt1->fetch(PDO::FETCH_ASSOC);
$stmt2 = $pdo->prepare("SELECT file_path FROM profile_pictures WHERE user_id = :user_id");
$stmt2->execute([':user_id' => $userId]);
$profile_pic = $stmt2->fetch(PDO::FETCH_ASSOC);
$stmt3 = $pdo->prepare("
SELECT users.username, profile_pictures.file_path
FROM users
LEFT JOIN profile_pictures ON users.id = profile_pictures.user_id
ORDER BY profile_pictures.uploaded_at DESC
");
$stmt3->execute();
$users = $stmt3->fetchAll(PDO::FETCH_ASSOC);
if ($profile_pic) {
$profile_image = $profile_pic['file_path'];
} else {
$profile_image = 'profile-pics/default.jpeg';
}
if(!$user){
die("Benutzer nicht gefunden!");
}
}catch (PDOException $e){
die("Fehler: " . $e->getMessage());
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php echo '<link rel="stylesheet" href="style.css?v='.time().'">'; ?>
<title>Profile</title>
</head>
<body>
<div class="container">
<div class="col-3">
<div class="navigation-body">
<h1>
<?php echo "<img class = 'profile-pictures' src='$profile_image' alt='pv' width='50'>";?>
<a href=""><?php echo htmlspecialchars($user['username']); ?></a>
</h1>
<ul>
<li><a href="">Home</a></li>
<li><a href="">Profil</a></li>
<li><a href="">Nachrichten</a></li>
<li><a href="">Benachrichtiungen</a></li>
</ul>
</div>
<div class="navigation-body">
<ul>
<?php foreach ($users as $benutzer): ?>
<li>
<img src="<?= htmlspecialchars($benutzer['file_path']) ?: 'profile-pics/default.jpeg' ?>" alt="Profilbild">
<a href="index.php?user=<?= urlencode($benutzer['username']) ?>"><?= htmlspecialchars($benutzer['username']) ?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
<div class="profile-body col-9">
<div class="profile-header">
<h1>Willkommen, <?php echo htmlspecialchars($user['username']); ?>!</h1>
<p>Email: <?php echo htmlspecialchars($user['email']); ?>!</p>
<p>Regestriert seit:, <?php echo htmlspecialchars($user['created_at']); ?>!</p>
<a href="logout.php">Abmelden</a>
<a href="?page=posts">Posts</a>
<a href="?page=about">Über mich</a>
<a href="?page=settings">Einstellungen</a>
</div>
<div class="posts-body">
<?php
if($page == 'posts'){
echo "<h1>Posts</h1>
<button>Post</button>
";
}elseif($page == 'about'){
echo "<h1>Über mich</h1>";
}elseif($page == 'settings'){
echo "
<h1>Einstellungen</h1>
<h3>Profilbild änderen</h3>
<form action='upload-profile/upload.php' method='post' enctype='multipart/form-data'>
<input type='file' name='profile_picture' accept='image/*' required>
<br>
<button type='submit'>Profilbild hochladen</button>
</form>
<h3>Profilbild löschen</h3>
<form action='upload-profile/delete-pb.php'>
<button type='submit'>Profilbild löschen</button>
</form>
";
echo $profile_image;
}
?>
</div>
<!--------------------Vorübergehende anzeige--->
<div class="post-formular-body">
<?php
if($page == 'posts'){
echo "
<form action='upload-post/upload-post.php' method='post' enctype='multipart/form-data'>
<textarea name='text_content' required placeholder='Schreibe etwas...'></textarea>
<input type='file' name='image'>
<button type='submit'>Posten</button>
</form>
";
$stmt45 = $pdo->prepare("
SELECT posts.*, profile_pictures.file_path AS profile_picture, users.username
FROM posts
LEFT JOIN profile_pictures ON posts.user_id = profile_pictures.user_id
LEFT JOIN users ON posts.user_id = users.id
WHERE posts.user_id = :user_id
ORDER BY posts.created_at DESC
");
$stmt45->execute([':user_id' => $userId]);
$posts = $stmt45->fetchAll(PDO::FETCH_ASSOC);
}
?>
</div>
<?php foreach ($posts as $post): ?>
<div class="post">
<img src="<?= htmlspecialchars($post['profile_picture']) ?: 'profile-pics/default.jpeg'; ?>" width="50px" alt="">
<p><strong>User #<?php echo $post['user_id']; ?></strong> schrieb:</p>
<p><?php echo nl2br(htmlspecialchars($post['text_content'])); ?></p>
<?php if (!empty($post['image_path'])): ?>
<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>
<form action="upload-post/delete-post.php" method="post">
<input type="hidden" name="post_id" value="<?php echo htmlspecialchars($post['id']); ?>">
<button type="submit">Delete</button>
</form>
</div>
<?php endforeach; ?>
<!--------------------Vorübergehende anzeige ende--->
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,171 @@
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: Arial, sans-serif;
background-color: #FAFBFF;
}
.container {
height: 100vh;
max-width: 1200px;
margin: 0 auto;
padding: 0 15px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.login-logo h1{
margin: 0;
}
.login-logo{
height: 50px;
width: 50px;
}
[class*="col-"] {
padding: 0 15px;
flex: 0 0 auto;
}
.login-body{
width: 100%;
height: auto;
text-align: center;
background-color: #FFFFFF;
border: solid 1px #ECF0F5;
padding: 12px;
border-radius: 20px;
display: flex;
flex-direction: column;
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.25);
align-items: center;
}
.login-body h2{
font-size: 40px;
margin-top: 10px;
margin-bottom: 10px;
}
.login-form{
display: flex;
flex-direction: column;
width: 95%;
}
.login-form a{
text-align: right;
text-decoration: none;
color: black;
font-style: italic;
font-size: 15px;
margin-top: 5px;
opacity: 60%;
}
.login-form input {
margin-top: 15px;
padding: 10px;
border: 1px solid #E2E8F0;
border-radius: 20px;
font-size: 16px;
color: #333;
background-color: #f9f9f9;
outline: none;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.login-form input:hover {
border-color: #888;
}
.login-form input:focus {
border-color: #007BFF;
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}
.login-form input::placeholder {
color: #aaa;
font-style: italic;
}
.login-button{
padding: 10px;
color: white;
background-color: black;
border: none;
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.25);
font-size: 15px;
border-radius: 20px;
transition: all 0.3s ease, box-shadow 0.3s ease;
margin-top: 20px;
font-size: 18px;
}
.login-button:hover{
cursor: pointer;
opacity: 75%;
}
.login-body a, p{
text-decoration: none;
color: #333;
transition: all 0.3s ease, box-shadow 0.3s ease;
}
.login-body a:hover{
opacity: 70%;
}
[class*="col-"] {
padding: 15px;
flex: 0 0 auto;
box-sizing: border-box;
}
.col-1 { flex: 0 0 8.33%; max-width: 8.33%; }
.col-2 { flex: 0 0 16.66%; max-width: 16.66%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.33%; max-width: 33.33%; }
.col-5 { flex: 0 0 41.66%; max-width: 41.66%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.33%; max-width: 58.33%; }
.col-8 { flex: 0 0 66.66%; max-width: 66.66%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.33%; max-width: 83.33%; }
.col-11 { flex: 0 0 91.66%; max-width: 91.66%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }
@media (max-width: 768px){
[class*="col-"] {
max-width: 70%;
}
}
@media (max-width: 456px){
[class*="col-"] {
max-width: 90%;
}
}

View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="de">
<head>
<link rel="stylesheet" href="login-page-style.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FVS-Social</title>
</head>
<body>
<div class="container" >
<div class="col-4 login-body" >
<img class="login-logo" src="../img/Logomark.png" alt="Logo">
<h2>Log In</h2>
<form class="login-form" action="login.php" method="POST">
<input type="email" placeholder="E-Mail oder Benutzername" name="email">
<input type="password" placeholder="Passwort" name="password">
<a href="">Passwort vergessen?</a>
<button class="login-button" name="login" type="submit">Log In</button>
</form>
<p>Noch kein Account?<a href="../signup/signup-page.html">Jetzt Regestrieren!</a></p>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,33 @@
<?php
include '../db_connect.php';
if(isset($_POST['login'])){
//aus input felder wird email und password gelesen und "bereinigt" d.h alle leerzeichen werden entfernt in eine Variable gespeichert
$email = trim($_POST['email']);
$password = trim($_POST['password']);
try{
//SQL script wird ausgeführt in der Variable $stmt
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = :email");
$stmt->execute([':email' => $email]);
//überprüfung ob emailadresse ein Benutzer hat
$user =$stmt->fetch(PDO::FETCH_ASSOC);
if($user && password_verify($password, $user['password'])) {
session_start();
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
header("Location: ../index.php");
}else{
echo "Ungültig. Versuche es nochmal: <a href='login-page.html'>Nochmal versuchen</a>";
}
}catch (PDOException $e) {
echo "Fehler: " . $e->getMessage();
}
}
?>

8
FVS-Social/logout.php Normal file
View file

@ -0,0 +1,8 @@
<?php
session_start();
session_unset();
session_destroy();
header("Location: login/login-page.html");
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 KiB

View file

@ -0,0 +1,175 @@
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: Arial, sans-serif;
background-color: #FAFBFF;
}
.container {
height: 100vh;
max-width: 1200px;
margin: 0 auto;
padding: 0 15px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.login-logo h1{
margin: 0;
}
.login-logo{
height: 50px;
width: 50px;
}
[class*="col-"] {
padding: 0 15px;
flex: 0 0 auto;
}
.login-body{
width: 100%;
height: auto;
text-align: center;
background-color: #FFFFFF;
border: solid 1px #ECF0F5;
padding: 12px;
border-radius: 20px;
display: flex;
flex-direction: column;
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.25);
align-items: center;
}
.login-body h2{
font-size: 40px;
margin-top: 10px;
margin-bottom: 10px;
}
.login-form{
display: flex;
flex-direction: column;
width: 95%;
}
.login-form a{
text-align: right;
text-decoration: none;
color: black;
font-style: italic;
font-size: 15px;
margin-top: 5px;
opacity: 60%;
}
.login-form input {
margin-top: 15px;
padding: 10px;
border: 1px solid #E2E8F0;
border-radius: 20px;
font-size: 16px;
color: #333;
background-color: #f9f9f9;
outline: none;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.login-form input:hover {
border-color: #888;
}
.login-form input:focus {
border-color: #007BFF;
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}
.login-form input::placeholder {
color: #aaa;
font-style: italic;
}
.login-button{
padding: 10px;
color: white;
background-color: black;
border: none;
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.25);
font-size: 15px;
border-radius: 20px;
transition: all 0.3s ease, box-shadow 0.3s ease;
margin-top: 20px;
font-size: 18px;
}
.login-button:hover{
cursor: pointer;
opacity: 75%;
}
.login-body a, p{
text-decoration: none;
color: #333;
transition: all 0.3s ease, box-shadow 0.3s ease;
}
.login-body a:hover{
opacity: 70%;
}
[class*="col-"] {
padding: 15px;
flex: 0 0 auto;
box-sizing: border-box;
}
.col-1 { flex: 0 0 8.33%; max-width: 8.33%; }
.col-2 { flex: 0 0 16.66%; max-width: 16.66%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.33%; max-width: 33.33%; }
.col-5 { flex: 0 0 41.66%; max-width: 41.66%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.33%; max-width: 58.33%; }
.col-8 { flex: 0 0 66.66%; max-width: 66.66%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.33%; max-width: 83.33%; }
.col-11 { flex: 0 0 91.66%; max-width: 91.66%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }
@media (max-width: 768px){
[class*="col-"] {
max-width: 70%;
}
}
@media (max-width: 456px){
[class*="col-"] {
max-width: 90%;
}
}

View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="de">
<head>
<link rel="stylesheet" href="signup-page-style.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FVS-Social</title>
</head>
<body>
<div class="container" >
<div class="col-4 login-body" >
<img class="login-logo" src="../img/Logomark.png" alt="Logo">
<h2>Sign Up</h2>
<form class="login-form" action="signup.php" method="POST">
<input type="text" placeholder="Benutzername" name="username">
<input type="email" placeholder="E-Mail" name="email">
<input type="password" placeholder="Passwort" name="password">
<button class="login-button" name="signup" type="submit">Regestrieren</button>
</form>
<p>Bereits angemeldet?<a href="../login/login-page.html">Jetzt Einloggen!</a></p>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,34 @@
<?php
include '../db_connect.php';
if(isset($_POST['signup'])){
$username = trim($_POST['username']);
$email = trim($_POST['email']);
$password = trim($_POST['password']);
//Password verschlüsseln
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
//mit try befehl wird geschaut ob es bereits ein Nutzer mit dem selben username gibt oder ob es auch andere Fehler gibt
try{
//Username, Email und verschlüsseltes Password wird in die Datenbank geschrieben
$stmt = $pdo->prepare("INSERT INTO users (username, email, password) VALUES (:username, :email, :password)");
$stmt->execute([
':username' => $username,
':email' => $email,
':password' => $hashedPassword
]);
header("Location: ../index.php");
}catch (PDOException $e){
if($e->getCode() == 23000){
header("Location: ../userused.html");
}else {
echo "Fehler: " . $e->getMessage();
}
}
}
?>

103
FVS-Social/style.css Normal file
View file

@ -0,0 +1,103 @@
* {
box-sizing: border-box;
}
.profile-pictures, .navigation-body ul li img { width: 50px; height: 50px; border-radius: 50%; }
body {
margin: 0;
font-family: Arial, sans-serif;
background-color: #FAFBFF;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 15px;
display: flex;
flex-direction: row;
height: auto;
}
.navigation-body{
background-color: #FFFFFF;
border: solid 1px #ECF0F5;
width: 100%;
border-radius: 20px;
}
.profile-header{
background-color: #FFFFFF;
border: solid 1px #ECF0F5;
width: 100%;
border-radius: 20px;
}
.post-pics{
max-width: 500px;
height: auto;
}
.posts-body {
background-color: #FFFFFF;
border: solid 1px #ECF0F5;
width: 100%;
border-radius: 20px;
}
.post-formular-body, .post{
background-color: #FFFFFF;
border: solid 1px #ECF0F5;
width: 100%;
border-radius: 20px;
}
.all-posts-body{
background-color: #FFFFFF;
border: solid 1px #ECF0F5;
width: 100%;
border-radius: 20px;
}
[class*="col-"] {
padding: 15px;
flex: 0 0 auto;
box-sizing: border-box;
}
.col-1 { flex: 0 0 8.33%; max-width: 8.33%; }
.col-2 { flex: 0 0 16.66%; max-width: 16.66%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.33%; max-width: 33.33%; }
.col-5 { flex: 0 0 41.66%; max-width: 41.66%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.33%; max-width: 58.33%; }
.col-8 { flex: 0 0 66.66%; max-width: 66.66%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.33%; max-width: 83.33%; }
.col-11 { flex: 0 0 91.66%; max-width: 91.66%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }
@media (max-width: 768px){
[class*="col-"] {
max-width: 70%;
}
.container{
flex-wrap: wrap;
}
}
@media (max-width: 456px){
[class*="col-"] {
max-width: 90%;
}
.container{
flex-wrap: wrap;
}
}

View file

@ -0,0 +1,32 @@
<?php
session_start();
include '../db_connect.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!isset($_SESSION['user_id'])) {
die("Du bist nicht eingeloggt!");
}
$userId = $_SESSION['user_id'];
$postId = $_POST['post_id'];
$stmt = $pdo->prepare("SELECT * FROM posts WHERE id = :id AND user_id = :user_id");
$stmt->execute([':id' => $postId, ':user_id' => $userId]);
$post = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$post) {
die("Post nicht gefunden oder keine Berechtigung, diesen Post zu löschen.");
}
$stmt = $pdo->prepare("DELETE FROM posts WHERE id = :id");
$stmt->execute([':id' => $postId]);
if (!empty($post['image_path']) && file_exists('../' . $post['image_path'])) {
unlink('../' . $post['image_path']);
}
header("Location: ../index.php?page=posts");
exit;
}

View file

@ -0,0 +1,41 @@
<?php
include '../db_connect.php';
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
$user_id = $_SESSION['user_id'];
$text_content = $_POST['text_content'];
$image_path = NULL;
if(!empty($_FILES['image']['name'])){
$upload_dir = "../posts/";
$target_dir = "posts/";
$filename = $user_id . "_" . basename($_FILES['image']['name']);
$target_file = $upload_dir . $filename;
if(move_uploaded_file($_FILES['image']['tmp_name'], $target_file)){
$image_path = $target_dir . $filename;
}
}
$stmt = $pdo->prepare("INSERT INTO posts (user_id, text_content, image_path) VALUES (:user_id, :text_content, :image_path)");
$stmt->execute([
':user_id' => $user_id,
':text_content' => $text_content,
':image_path' => $image_path
]);
header("Location: ../index.php");
exit();
}
?>

View file

@ -0,0 +1,27 @@
<?php
session_start();
include "../db_connect.php";
$userId = $_SESSION['user_id'];
$stmt = $pdo->prepare("SELECT file_path FROM profile_pictures WHERE user_id = :id");
$stmt->execute([':id' => $userId]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if($user && !empty($user['file_path'])){
$file_Path = "../" . $user['file_path'];
if(file_exists($file_Path)){
unlink($file_Path);
}
$stmt = $pdo->prepare("DELETE FROM profile_pictures WHERE user_id = :id");
$stmt->execute([':id' => $userId]);
}
header("Location: ../index.php");
exit;
?>

View file

@ -0,0 +1,5 @@
<?php
?>

View file

@ -0,0 +1,68 @@
<?php
session_start();
include '../db_connect.php';
if (!isset($_SESSION['user_id'])) {
die("Du musst eingeloggt sein!");
}
$user_id = $_SESSION['user_id'];
$upload_dir = "../profile-pics/";
$max_size = 2 * 1024 * 1024;
if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_FILES['profile_picture'])) {
$file = $_FILES['profile_picture'];
$file_name = basename($file['name']);
$file_tmp = $file['tmp_name'];
$file_size = $file['size'];
$file_ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
$allowed_ext = ["jpg", "jpeg", "png", "gif"];
if (!in_array($file_ext, $allowed_ext)) {
die("Nur JPG, JPEG, PNG und GIF erlaubt.");
}
if ($file_size > $max_size) {
die("Datei ist zu groß (max. 2MB).");
}
$stmt1 = $pdo->prepare("SELECT file_path FROM profile_pictures WHERE user_id = :id");
$stmt1->execute([':id' => $user_id]);
$user = $stmt1->fetch(PDO::FETCH_ASSOC);
if($user && !empty($user['file_path'])){
$file_Path3 = "../" . $user['file_path'];
if(file_exists($file_Path3)){
unlink($file_Path3);
}
$stmt = $pdo->prepare("DELETE FROM profile_pictures WHERE user_id = :id");
$stmt->execute([':id' => $user_id]);
}
$new_file_name = "profile_" . $user_id . "." . $file_ext;
$file_path = $upload_dir . $new_file_name;
$file_path1 = "profile-pics/" . $new_file_name;
if (move_uploaded_file($file_tmp, $file_path)) {
$stmt = $pdo->prepare("INSERT INTO profile_pictures (user_id, file_path) VALUES (:user_id, :file_path)
ON DUPLICATE KEY UPDATE file_path = VALUES(file_path)");
$stmt->execute([':user_id' => $user_id, ':file_path' => $file_path1]);
header("Location: ../index.php");
} else {
echo "Fehler beim Hochladen. Prüfe Folgendes:<br>";
echo "Temp-Datei: " . htmlspecialchars($file_tmp) . "<br>";
echo "Ziel-Pfad: " . htmlspecialchars($file_path) . "<br>";
if (!is_writable($upload_dir)) {
echo " Fehler: Der Ordner '$upload_dir' ist nicht beschreibbar!<br>";;
}
}
}
?>

11
FVS-Social/userused.html Normal file
View file

@ -0,0 +1,11 @@
<!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>Benutzer bereits vergeben!</h1>
</body>
</html>