Show sourcecode
The following files exists in this folder. Click to view.
webbsrvprg/projects/slutprojekt/
class/
create-categories.php
create-recipe.php
css/
db_content.php
forgot_password.php
include/
login.php
logout.php
recipe-search.php
recipe.php
reset_password.php
signin.php
start.php
tabeller/
verify.php
start.php
73 lines UTF-8 Windows (CRLF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
session_start();
include('../../dbconnection.php');
ob_clean();
include('include/session-variables.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/styles.css">
<title>Start</title>
</head>
<body>
<div id="page-container">
<div id="content-wrap">
<?php
include('include/header.php');
?>
<main>
<h1>Vad vill du koka idag?</h1>
<form id="searchForm" action="" method="get">
<div class="center">
<input type="search" id="searchbar" placeholder="Sök recept eller kategori" aria-label="Sök">
</div>
</form>
<div id="results-container">
<div id="results">
</div>
</div>
</main>
<?php
include('include/footer.php');
?>
</div>
</div>
<script>
const searchInput = document.getElementById('searchbar');
const searchForm = document.getElementById('searchForm');
searchInput.addEventListener('keyup', function () {
showRecipes(this.value);
});
searchForm.addEventListener('submit', function (event) {
event.preventDefault();
showRecipes(searchInput.value);
});
async function showRecipes (str){
if (str.length < 2) {
document.getElementById("results").innerHTML = "";
}
else {
let myObject = await fetch("recipe-search.php?recipe=" + str);
let myText = await myObject.text();
document.getElementById("results").innerHTML = myText;
}
}
</script>
</body>
</html>