forked from armondressler/webdev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listPatients.php
39 lines (30 loc) · 851 Bytes
/
listPatients.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
<?php
session_start();
// First, we test if user is logged. If not, goto main.php (login page).
if(!isset($_SESSION['user'])){
header("Location: main.php");
exit();
}
include('pdo.inc.php');
try {
$dbh = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password);
/*** echo a message saying we have connected ***/
echo '<h1>List of patients</h1>';
$sql = "select * from patient";
$result = $dbh->query($sql);
while($line = $result->fetch()){
echo "<a href='viewPatient.php?id=".$line['patientID']."'>";
echo $line['first_name']." ".$line['name'];
echo "</a><br>\n";
}
$dbh = null;
}
catch(PDOException $e)
{
/*** echo the sql statement and error message ***/
echo $e->getMessage();
}
echo "<br>User =".$_SESSION['user'];
?>
<br />
<i><a href="logout.php">Logout</a></i>