コード例 #1
0
ファイル: oef92.php プロジェクト: rvaliev/samverhoeven
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>
		<?php 
$tab = $fl->getLijst();
foreach ($tab as $film) {
コード例 #2
0
        print_r($films);
        $sql = "update films set titel = :titel, duurtijd = :duurtijd where id = :id";
        $dbh = new PDO("mysql:host=localhost;dbname=cursusphp;charset=utf8", "root", "");
        $stmt = $dbh->prepare($sql);
        $resultSet = $stmt->execute(array(':id' => $films->getId(), ':titel' => $films->getTitel(), ':duurtijd' => $films->getDuurtijd()));
        $stmt->execute();
        $dbh = null;
    }
}
$filmlijst = new FilmLijst();
if (isset($_GET["action"]) && $_GET["action"] == "new") {
    $filmlijst->createFilm($_POST["titel"], $_POST["duurtijd"]);
}
if (isset($_GET["action"]) && $_GET["action"] == "delete") {
    $filmLijst2 = new FilmLijst();
    $filmLijst2->deleteFilm($_GET["id"]);
}
$updated = false;
if (isset($_GET["action"]) && $_GET["action"] == "bewerk") {
    $film = new Film($_GET["id"], $_GET["titel"], $_GET["duurtijd"]);
    $filmLijst = new FilmLijst();
    $filmLijst->updateFilm($film);
    $updated = true;
}
?>