Add 'index.php'

main
ezn 3 years ago
parent 8710eec2a6
commit 2b6dc13780

@ -0,0 +1,49 @@
<?php
session_start();
// remove next 3 lines when you're done, so that errors don't show up in a browser
ini_set("display_errors", "1");
ini_set("display_startup_errors", "1");
error_reporting(E_ALL);
if (isset($_SESSION["user_id"])) {
$mysqli = require __DIR__ . "/database.php";
$sql = "SELECT * FROM user WHERE id = {$_SESSION["user_id"]}";
$result = $mysqli->query($sql);
$user = $result->fetch_assoc();
}
?>
<!DOCTYPE html>
<html>
<head>
<!-- we need to edit these ------------------------------------------------- - -->
<!-- we need to edit these ------------------------------------------------- - -->
<!-- we need to edit these ------------------------------------------------- - -->
<title>Home</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
</head>
<body>
<h1>Home</h1>
<?php if (isset($user)): ?>
<p>Hello <?= htmlspecialchars($user["name"]) ?></p>
<p><a href="logout.php">Log out</a></p>
<?php else: ?>
<p><a href="login.php">Log in</a> or <a href="signup.html">sign up</a></p>
<?php endif; ?>
</body>
</html>
Loading…
Cancel
Save