-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategorie-toevoegen.php
67 lines (58 loc) · 1.8 KB
/
categorie-toevoegen.php
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
<?php
require_once('functions.php');
$error = '';
if (isset($_POST['action'])) {
if ($_POST['action']==ACT_ADD) {
$title = trim($_POST['newtitle']);
if ($title != '') {
$dbh = new PDO(DATABASE, DB_USER, DB_PASSWORD);
$dbh->beginTransaction();
$stmt = $dbh->prepare('INSERT INTO content_category (title) VALUES (:title)');
$stmt->bindParam(':title', $title, PDO::PARAM_STR, 15);
$stmt->execute();
$dbh->commit();
$dbh = null;
// header('Location: '.$_SERVER['PHP_SELF']);
}
}
}
?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title><?php echo OWNER; ?></title>
<link rel="stylesheet" href="toevoegen.css" type="text/css" />
</head>
<body>
<form method="post">
<fieldset>
<legend>Categorie Toevoegen</legend>
<label for="newtitle" style="display: block; width: 110px; float: left; clear: both;">Titel:</label> <input id="newtitle" name="newtitle" type="text" />
<input name="action" type="submit" value="<?php echo ACT_ADD;?>" class="button" style="clear: both; width: auto;" />
</fieldset>
</form>
<form method="post">
<fieldset>
<legend>Bestaande Categorien</legend>
<table>
<tr>
<th>Categorie</th>
</tr>
<?php
$dbh = new PDO(DATABASE, DB_USER, DB_PASSWORD);
$stmt = $dbh->query('SELECT title FROM content_category ORDER BY idx;');
$result = $stmt->fetchAll();
$dbh = null;
if (is_array($result)) {
foreach ($result as $entry) {
echo '<tr><td>'.$entry['title'].'</td></tr>';
}
}
?>
</table>
</fieldset>
</form>
<a href="template-toevoegen.php" style="float: right;">Terug</a>
</body>
</html>