To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <meta charset="UTF-8"> <title>filmoverzicht</title> <style> span, input {margin-bottom: 0.5em; margin-top: 0.5em;} </style> </head> <body> <h1>Alle Films</h1> <?php $pl = new FilmLijst(); $tab = $pl->getLijst(); ?> <ul> <?php foreach ($tab as $naam) { print "<li>" . $naam . "</li>"; } ?> </ul> <h1>Film toevoegen</h1> <form action="alleFilmsLijstEnForm.php" method="post"> <span>Titel: <input type="text" name="filmtitel" placeholder="filmtitel" autofocus=""></span> </br> <span>Duurtijd: <input type="text" name="duurtijd" placeholder="duurtijd"> minuten</span> </br>
<?php require_once './93filmGegevens.php'; $filmGegevens = new FilmLijst(); //Is de invoer van de invoervelden juist? Voer dan de functie uit om een film aan te maken //en post de titel en duurtijd als parameters if (isset($_POST["titel"]) && $_POST["duurtijd"] >= 0) { $filmGegevens->maakFilm($_POST["titel"], $_POST["duurtijd"]); } //voor het aanroepen van delete dat in de delete knop zit. if (isset($_GET["action"]) && $_GET["action"] == "delete") { $filmGegevens->verwijder($_GET["id"]); } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <h1>Alle films</h1> <?php //maak een lijst aan $tab = $filmGegevens->getLijst(); //voor elke film in de tabel word de titel opgeroepen en de duurtijd. //De delete knop heeft een link waarin een action delete staat met een dynamisch ID //het id komt uit film foreach ($tab as $film) { echo $film->getTitel() . " - " . $film->getDuurtijd() . " - "; ?>
$film = new Film($_GET["id"], $_POST["titel"], $_POST["duurtijd"]); $filmLijst = new FilmLijst(); $filmLijst->updateFilm($film); $updated = true; } ?> <!DOCTYPE HTML> <html> <head><title>Films</title></head> <body> <h1>Film bewerken</h1> <?php if ($updated) { print "Record bijgewerkt!"; } $filmLijst = new FilmLijst(); $film = $filmLijst->getFilmById($_GET["id"]); ?> <form action="filmbewerken.php?action=verwerk&id=<?php print $_GET["id"]; ?> " method="post"> Titel: <input type="text" name="titel" value="<?php print $film->getTitel(); ?> "><br><br> Duurtijd: <input type="text" name="duurtijd" value="<?php print $film->getDuurtijd(); ?>
} } public function getLijst() { $lijst = array(); $dbh = new PDO("mysql:host=localhost;dbname=cursusphp", "root", ""); $resultSet = $dbh->query("select titel, duurtijd from films order by titel"); foreach ($resultSet as $rij) { $film = $rij["titel"] . " (" . $rij["duurtijd"] . " min)"; array_push($lijst, $film); } $dbh = null; return $lijst; } } $filmlijst = new FilmLijst(); if (isset($_GET["action"]) && $_GET["action"] == "new") { $filmlijst->createFilm($_POST["titel"], $_POST["duurtijd"]); } ?> <!DOCTYPE HTML> <html> <head><title>Films</title></head> <body> <h1>Alle films</h1> <?php $tab = $filmlijst->getLijst(); ?> <ul> <?php foreach ($tab as $film) {
<?php require_once "film.class.php"; require_once "filmlijst.class.php"; session_start(); $fl = new FilmLijst(); if (isset($_POST['addBtn'])) { if (isset($_GET["action"]) && $_GET["action"] == "new") { $fl->createFilm($_POST["titel"], $_POST["duurtijd"]); if (!is_numeric($_POST["duurtijd"]) || $_POST["duurtijd"] <= 0 || empty($_POST["titel"])) { $_SESSION["foutbericht"] = "De gegeven invoer is niet geldig."; } else { $_SESSION["foutbericht"] = null; } header("Refresh: 0"); } } if (isset($_GET["action"]) && $_GET["action"] == "delete") { $fl->deleteFilm($_GET["id"]); } ?> <!DOCTYPE HTML> <html> <head> <meta charset=utf-8> <title>Films</title> </head> <body> <h1>Alle films</h1> <ul>
<head> <meta charset="UTF-8"> <title>Gegevens bewerken</title> <style> input {margin-top: 0.5em; margin-bottom: 0.5em;} #Back {display: block; margin-top: 2em; } input:focus {background-color: yellow;} </style> </head> <body> <h1>Film bijwerken</h1> <?php if ($updated) { print "Record bijgewerkt!"; } $gfbid = new FilmLijst(); $film = $gfbid->getFilmsById($_GET["id"]); $filmTitel = $film->getTitel(); $filmDuur = $film->getDuurtijd(); ?> <form action="filmsBewerken.php?action=verwerk&id=<?php print $_GET["id"]; ?> " method="post"> Titel: <input type="text" name="titel" value="<?php print $filmTitel; ?> " autofocus="yellow"> </br> Duurtijd: <input type="text" name="duurtijd" value="<?php print $filmDuur;
require_once './92filmGegevens.php'; if (isset($_POST["titel"]) && $_POST["duurtijd"] >= 0) { $filmlijst = new FilmLijst(); $filmlijst->maakFilm($_POST["titel"], $_POST["duurtijd"]); } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <h1>Alle films</h1> <?php $filmGegevens = new FilmLijst(); $tab = $filmGegevens->getLijst(); foreach ($tab as $film) { print "<li>" . $film . "</li>"; } ?> <h1>Film toevoegen</h1> <form action="" method="post"> <label for="titel">Titel</label> <input type="text" name="titel" required><br><br> <label for ="duurtijd">Duurtijd</label> <input type="number" min="1" name="duurtijd" required> minuten.<br><br> <input type="submit" value="Toevoegen"/> </body> </html>