-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
44 lines (28 loc) · 881 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
session_start();
if (isset($_SESSION["user_id"])) {
$mysqli = require __DIR__ . "/connect.php";
$sql = "SELECT * FROM artisan
WHERE artisan_ID = {$_SESSION["user_id"]}";
$result = $mysqli->query($sql);
$user = $result->fetch_assoc();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
</head>
<body>
<div class="index">
<h1>Home</h1>
<?php if (isset($user)): ?>
<p>Weclcome<?= htmlspecialchars($user["first_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>
<p>Session variable user_id is <?php echo isset($_SESSION["user_id"]) ? $_SESSION["user_id"] : "not set"; ?></p>
<?php endif; ?>
</div>
</body>
</html>