-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.php
75 lines (56 loc) · 1.98 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<title>9dc0a5e5</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
</head>
<?php
require "pdo.php";
session_start();
?>
<body>
<h1>Alan Dsilva's Resume Registry</h1>
<?php
if (isset($_SESSION['success'])) {
echo "<p style='color: green'>".$_SESSION['success']."</p>";
unset($_SESSION['success']);
}
if ( isset($_SESSION['name'])) {
echo "<a href='logout.php'>Logout</a><br />";
} else {
echo "<a href='login.php'>Please log in</a>";
}
$statement = $pdo->query("SELECT * FROM profile");
$row = $statement->fetch(PDO::FETCH_ASSOC);
if ($row != false) {
$statement = $pdo->query("SELECT * FROM profile");
echo "<table border='1'>
<tbody>
<tr>
<th>Name</th>
<th>Headline</th>";
if (isset($_SESSION['name'])) {
echo "<th>Action</th>";
}
echo "</tr>";
while ( $row = $statement->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>";
echo "<td>".$row['first_name']." ".$row['last_name']."</td>";
echo "<td>".$row['email']."</td>";
if (isset($_SESSION['name'])) {
echo "<td>
<a href='edit.php?profile_id=".$row['profile_id']."'>Edit </a>
<a href='delete.php?profile_id=".$row['profile_id']."'>Delete</a>
</td>";
}
echo "</tr>";
}
echo "</tbody></table>";
}
if ( isset($_SESSION['name'])) {
echo "<a href='add.php'>Add New Entry</a>";
}
?>
</body>
</html>