OebbApiWeb/home.php
2025-07-05 21:24:53 +02:00

97 lines
3.5 KiB
PHP

<?php
// We need to use sessions, so you should always initialize sessions using the below function
session_start();
// If the user is not logged in, redirect to the login page
if (!isset($_SESSION['account_loggedin'])) {
header('Location: index.php');
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1">
<title>Home</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script>
function suggest(val){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById('suggest_container').innerHTML=this.responseText;
}
};
xhttp.open("GET", ("suggest.php?type=station&name="+ encodeURI(val)), true);
xhttp.send();
}
function suggestStation(val){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById('suggest_stations').innerHTML=this.responseText;
}
};
xhttp.open("GET", ("suggest.php?type=stationName&name="+ encodeURI(val)), true);
xhttp.send();
}
</script>
</head>
<body>
<header class="header">
<div class="wrapper">
<h1>Website Title</h1>
<nav class="menu">
<a href="home.php">Home</a>
<a href="profile.php">Profile</a>
<a href="logout.php">
<svg width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M377.9 105.9L500.7 228.7c7.2 7.2 11.3 17.1 11.3 27.3s-4.1 20.1-11.3 27.3L377.9 406.1c-6.4 6.4-15 9.9-24 9.9c-18.7 0-33.9-15.2-33.9-33.9l0-62.1-128 0c-17.7 0-32-14.3-32-32l0-64c0-17.7 14.3-32 32-32l128 0 0-62.1c0-18.7 15.2-33.9 33.9-33.9c9 0 17.6 3.6 24 9.9zM160 96L96 96c-17.7 0-32 14.3-32 32l0 256c0 17.7 14.3 32 32 32l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-64 0c-53 0-96-43-96-96L0 128C0 75 43 32 96 32l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32z"/></svg>
Logout
</a>
</nav>
</div>
</header>
<div class="content">
<div class="page-title">
<div class="wrap">
<h2>Home</h2>
<p>Welcome back, <?=htmlspecialchars($_SESSION['account_name'], ENT_QUOTES)?>!</p>
</div>
</div>
<div class="block">
<p>This is the home page. You are logged in!</p>
<form>
Bildschirm 2:<br>
Name: <input type="text" name="title">
Abfahrtszeit: <input type="text" name="time">
Zug (z.b. REX 3): <input type="text" name="train">
Station: <input type="text" name="station" list="listit" onkeyup="suggest(this.value)" id="station">
Endstation des Zugs: <input type="text" name="endstation" list="liststations" onkeyup="suggestStation(this.value)" id="endstation">
<div id="suggest_container" style="display:inline-block;">
<datalist id="listit">
<option ></option>
</datalist>
</div>
<div id="suggest_stations" style="display:inline-block;">
<datalist id="liststations">
<option ></option>
</datalist>
</div>
</form>
</div>
</div>
</body>
</html>