Commit 1be3b308 authored by William Paul Liggett's avatar William Paul Liggett

Best of both worlds: Now the PHP and HTML source output whitespacing is pretty.

parent cb7ac89b
......@@ -13,21 +13,23 @@
<body>
<h1>OpenVigilance Task: Admin Page</h1>
<?php
// Makes the tab whitespace makes the HTML source look nice. There are 4 spaces.
$tab = " ";
// Displays if any login errors were detected.
$error_msg = "&nbsp;"; // No error = Non-breaking space character.
// Used to display an HTML login form on first load or if the username and password was incorrect.
// Note: The tab whitespace is weird to make the HTML source pretty.
$login_form = '
<form action="admin" name="AdminLogin" method="post">
<label for="username">Username:</label>
<input type="text" name="username" id="username" />
<br />
<label for="password">Password:</label>
<input type="password" name="password" id="password" />
<br />
<input type="submit" value="Submit" />
</form>' . PHP_EOL;
$login_form = PHP_EOL .
"$tab$tab<form action=\"admin\" name=\"AdminLogin\" method=\"post\">" . PHP_EOL .
"$tab$tab$tab<label for=\"username\">Username:</label>" . PHP_EOL .
"$tab$tab$tab<input type=\"text\" name=\"username\" id=\"username\" />" . PHP_EOL .
"$tab$tab$tab<br />" . PHP_EOL .
"$tab$tab$tab<label for=\"password\">Password:</label>" . PHP_EOL .
"$tab$tab$tab<input type=\"password\" name=\"password\" id=\"password\" />" . PHP_EOL .
"$tab$tab$tab<br />" . PHP_EOL .
"$tab$tab$tab<input type=\"submit\" value=\"Submit\" />" . PHP_EOL .
"$tab$tab</form>" . PHP_EOL;
// GET: The page upon first load, before the <form> has been submitted.
if($_SERVER['REQUEST_METHOD'] === "GET") {
......@@ -76,36 +78,32 @@
$num_rows = count($rows);
// Section heading.
echo '
<h2>Scheduled Tests</h2>';
echo "<h2>Scheduled Tests</h2>" . PHP_EOL;
if($num_rows > 0) {
// Sets up the <table> heading.
echo '
<table>
<thead>
<tr>
<th>Subject ID</th>
<th>Test Condition</th>
<th>Test PIN</th>
</tr>
</thead>
<tbody>';
echo "$tab$tab<table>" . PHP_EOL .
"$tab$tab$tab<thead>" . PHP_EOL .
"$tab$tab$tab$tab<tr>" . PHP_EOL .
"$tab$tab$tab$tab$tab<th>Subject ID</th>" . PHP_EOL .
"$tab$tab$tab$tab$tab<th>Test Condition</th>" . PHP_EOL .
"$tab$tab$tab$tab$tab<th>Test PIN</th>" . PHP_EOL .
"$tab$tab$tab$tab</tr>" . PHP_EOL .
"$tab$tab$tab</thead>" . PHP_EOL .
"$tab$tab$tab<tbody>" . PHP_EOL;
// The rows of the <table>.
foreach($rows as $key => $value) {
echo '
<tr>
<td>' . $value["subject_id"] . '</td>
<td>' . $value["test_condition"] . '</td>
<td>' . $value["test_pin"] . '</td>
</tr>';
echo "$tab$tab$tab$tab<tr>" . PHP_EOL .
"$tab$tab$tab$tab$tab<td>" . $value["subject_id"] . "</td>" . PHP_EOL .
"$tab$tab$tab$tab$tab<td>" . $value["test_condition"] . "</td>" . PHP_EOL .
"$tab$tab$tab$tab$tab<td>" . $value["test_pin"] . "</td>" . PHP_EOL .
"$tab$tab$tab$tab</tr>" . PHP_EOL;
}
// Closes out the <table>
echo '
</tbody>
</table>' . PHP_EOL;
echo "$tab$tab$tab</tbody>" . PHP_EOL .
"$tab$tab</table>" . PHP_EOL;
}
// There were no rows to display. More OV tests should be added.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment