Webbserv1: Källkod
Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/projects/slutprojekt/

blala.php
chat.php
createtable.php
delete.php
deletetable.php
deletetables.php
fetch_messages.php
filhantering/
footer.php
header.php
home.php
login.php
new_password.php
password_reset.php
profile.php
send_message.php
signup.php
verify.php

header.php

73 lines UTF-8 Windows (CRLF)
<?php
include('../../dbconnection.php');

if (isset(
$_SESSION['id'])) {
  
$sql "SELECT pictures.picture FROM pictures WHERE userId = ?";
  
$stmt $dbconn->prepare($sql);
  
$stmt->execute([$_SESSION['id']]);
  
$pic $stmt->fetch(PDO::FETCH_ASSOC);
  if (
$pic && !empty($pic['picture'])) {
    
$profilePic $pic['picture'];
  }
}
?>

<style>
  .header {
    background: linear-gradient(to right, #4e54c8, #8f94fb);
    color: white;
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: sans-serif;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
  }

  .header a {
    color: white;
    text-decoration: none;
    margin: 0 15px;
    font-weight: bold;
    transition: opacity 0.2s;
  }

  .header a:hover {
    opacity: 0.8;
  }

  .header .nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
  }

  .header img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    margin-left: 10px;
    border: 2px solid white;
    vertical-align: middle;
  }
</style>

<div class="header">
  <div class="nav-links">
    <a href="home.php">Hitta vänner</a>
    <a href="chat.php">Chat</a>
    <a href="login.php">Logga ut</a>
  </div>
  <?php 
    
if (isset($_SESSION['admin']) && $_SESSION['admin'] == 1) {
      echo 
"<a href='delete.php'>Delete</a>";
    }
  
?>
  <a href="profile.php">
    <?php echo htmlentities($_SESSION['fullname'] ?? 'Profil'); ?>
    <img src="<?php echo htmlentities($profilePic); ?>" alt="Profilbild">
  </a>
</div>