diff options
author | Mateja <mail@matejamaric.com> | 2020-09-28 19:14:53 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2020-09-28 19:14:53 +0200 |
commit | 00fda2f0dfdaa1129949f0fa116cfaeff23ab486 (patch) | |
tree | 7ff6596f038c84771484da6c8150ce441aad89c6 /index.php | |
download | old-php-yota-00fda2f0dfdaa1129949f0fa116cfaeff23ab486.tar.gz old-php-yota-00fda2f0dfdaa1129949f0fa116cfaeff23ab486.zip |
first commit
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/index.php b/index.php new file mode 100644 index 0000000..47b4069 --- /dev/null +++ b/index.php @@ -0,0 +1,61 @@ +<?php +session_start(); +?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"/> + <meta name="viewport" content="width=device-width initial-scale=1.0"/> + <link href="style.css" rel="stylesheet" type="text/css"/> + <title>Yota Callplan</title> +</head> +<body> +<header><a href="http://yota.yu1srs.org.rs/">YOTA</a></header> +<nav> + <a class="active" href="index.php">Activity Plan</a> + <a href="reservation.php">Make reservation</a> +<?php + if (isset($_SESSION['admin']) && $_SESSION['admin'] == true) { + echo '<a class="right" href="/logout.php">Logout</a>'; + echo '<a class="right" href="admin.php">Administration</a>'; + } else { + echo '<a class="right" href="/admin.php">Login</a>'; + } +?> +</nav> +<main> +<?php + $user = "yota_user"; + $password = "leex3EThieK0ieLaiVaicaifef5eecei"; + $database = "yota_call_db"; + $table = "activities"; + + try { + $db = new PDO("mysql:host=localhost;dbname=$database", $user, $password); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + echo '<div style="overflow-x:auto;">'; + echo "<table>\n"; + echo "<tr>"; + echo "<th>Ime</th>"; + echo "<th>Prezime</th>"; + echo "<th>Godine</th>"; + echo "</tr>\n"; + + foreach($db->query("SELECT * FROM $table where approved=true") as $row) { + echo "<tr>"; + echo "<td>" . $row['name'] . "</td>"; + echo "<td>" . $row['surname'] . "</td>"; + echo "<td>" . $row['age'] . "</td>"; + echo "</tr>\n"; + } + + echo "</table>\n</div>\n"; + } catch (PDOException $e) { + echo "<p>Error!: " . $e->getMessage() . "</p>"; + die(); + } +?> +</main> +</body> +</html> |