Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <?php
- session_start();
- if(isset($_SESSION['status'])) {
- echo "<br>currently logged in: " . $_SESSION["name"] . ".<br>";
- }
- else
- {
- session_destroy();
- header("Location: runnerLoginForm.html");
- }
- ?>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Untitled Document</title>
- </head>
- <body>
- <style>
- body, html {
- height: 100%;
- background-color: azure;
- font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
- text-align: center;
- }
- div {
- border: 1px solid gray;
- padding: 8px;
- }
- h1 {
- text-align: center;
- text-transform: uppercase;
- color: #4CAF50;
- letter-spacing: 10px;
- text-size: 20px;
- }
- p {
- text-align: center;
- letter-spacing: 3px;
- }
- td, th {
- border: 1px solid green;
- padding: 0.5rem;
- text-align: center;
- }
- table {
- border-collapse: collapse;
- }
- a:link, a:visited {
- background-color: #4CAF50;
- color: white;
- padding: 14px 25px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- }
- a:hover, a:active {
- background-color: #4CAF50;
- }
- </style>
- <h1>XC Attendance
- </h1>
- <p>
- <a href="runnerHome.php">Your Log</a>
- <a href="runnerAbsencePostForm.html">Post your absence</a>
- <a href="runnerHome.php?hello=true">Logout</a>
- </p>
- <br>
- <h1>Dates Absent</h1>
- <br>
- <?php
- $name = $_SESSION["name"];
- function logout()
- {
- session_destroy();
- // echo "refreshing";
- header("Location: runnerLoginForm.html");
- }
- if (isset($_GET['hello']))
- {
- logout();
- // setcookie("user", "", time() - 3600);
- }
- echo "<table align='center'>";
- echo "<tr><th>id</th><th>absence_date</th><th>explanation</th><th>time</th><th>review status</th><th>review date</th></tr>";
- class TableRows extends RecursiveIteratorIterator
- {
- function __construct($it)
- {
- parent::__construct($it, self::LEAVES_ONLY);
- }
- function current()
- {
- return "<td style='width:150px;border:1px solid green;'>" . parent::current() . "</td>";
- }
- function beginChildren()
- {
- echo "<tr>";
- }
- function endChildren()
- {
- echo "</tr>" . "\n";
- }
- }
- $servername = "localhost";
- $username = "playground18";
- $password = "Cdz5SOVrY2p8fnWS";
- $dbname = "playground18";
- try
- {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $stmt = $conn->prepare("SELECT * ");
- // $stmt->execute();
- // set the resulting array to associative
- /*$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
- foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v)
- {
- echo $v;
- }
- */
- $sql = "SELECT count(*) FROM `tanay_auction_items` WHERE id>0";
- $result = $conn->prepare($sql);
- $result->execute();
- $number_of_rows = $result->fetchColumn();
- $stmt = $conn->prepare("SELECT id, absence_date, explanation, time, review_status, review_date FROM tanay_xcatt_absences WHERE person='$name'");
- $stmt->execute();
- // set the resulting array to associative
- $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
- foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k => $v)
- {
- echo $v;
- }
- }
- catch(PDOException $e)
- {
- echo "Error: " . $e->getMessage();
- }
- $conn = null;
- echo "</table>";
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment