-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathedit-titles.php
69 lines (47 loc) · 1.19 KB
/
edit-titles.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
68
69
<?php
require_once('_includes/main.php');
if (!LOGGEDIN) {
header('Location: login.php');
exit();
}
switch (STEP) {
case 1:
default:
EditTitle::Step1();
break;
case 2:
EditTitle::Step2();
break;
case 3:
EditTitle::Step3();
}
class EditTitle
{
/*
Display the title ID field
*/
function Step1() {
$tpl = new Template(DOCUMENT_ROOT . '_templates/edit-titles.tpl');
$tpl->set('id', isset($_GET['id']) ? $_GET['id'] : '');
echo $tpl->fetch();
}
/*
Calls database to edit titles
*/
function Step2() {
if (isset($_POST['movie-id']) && is_numeric($_POST['movie-id']) && isset($_POST['original-title']) && strlen($_POST['original-title']) > 1 && isset($_POST['english-title'])) {
$db = new MDB();
$success = $db->editTitles($_POST['movie-id'], $_POST['original-title'], $_POST['english-title']);
if ($success)
header('Location: ' . WEB_ROOT . '?message=edit-titles-success');
else
header('Location: ' . WEB_ROOT . '?message=edit-titles-error');
exit();
}
else {
header('Location: ' . WEB_ROOT . '?message=edit-titles-error');
exit();
}
}
}
?>