Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <?php
- session_start();
- if(isset($_SESSION['status'])) {
- echo "session running";
- echo "<br>currently logged in: " . $_SESSION["name"] . ".<br>";
- }
- else
- {
- session_destroy();
- header("Location: auctionLoginForm.html");
- }
- ?>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Auction Home</title>
- </head>
- <body>
- <h1>Available items for purchase*:</h1>
- <h6>*Bidding and buying capabilities to be added later</h6>
- <h3><a href="auctionPostForm.html">Post an item up for auction</a>
- <?php
- function logout() {
- session_destroy();
- //echo "refreshing";
- header("Location: auctionLoginForm.html");
- }
- if (isset($_GET['hello'])) {
- logout();
- //setcookie("user", "", time() - 3600);
- }
- echo "<table style='border: solid 1px black;'>";
- echo "<tr><th>id</th><th>item</th><th>description</th><th>start bid price</th><th>post time</th><th>poster</th><th>expiration date</th><th>current bid price</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 black;'>" . 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 * FROM tanay_auction_items");
- $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>";
- ?>
- <a href='auctionHome.php?hello=true'>Logout</a>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement