-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.php
70 lines (53 loc) · 1.73 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
<!DOCTYPE html>
<html>
<head>
<title>3bfc8356</title>
<?php require_once "requirements.php" ?>
</head>
<?php
require "pdo.php";
require "util.php";
session_start();
?>
<body>
<h1>Alan Dsilva's Resume Registry</h1>
<?php
flash();
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><a href='view.php?profile_id=".$row['profile_id']."'>".$row['first_name']." ".$row['last_name']."</a></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>