-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.php
33 lines (29 loc) · 953 Bytes
/
controller.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
<?php
include 'model.php';
$database = new database();
$action = $_GET['action'];
if($action == "insert"){
$book_name = $_POST['book_name'];
$author = $_POST['author'];
$publisher = $_POST['publisher'];
$date_published = $_POST['date_published'];
$price = $_POST['price'];
$database->insert($book_name, $author, $publisher, $date_published, $price);
header("location:index.php");
}
elseif($action == "update"){
$book_id = $_POST['book_id'];
$book_name = $_POST['book_name'];
$author = $_POST['author'];
$publisher = $_POST['publisher'];
$date_published = $_POST['date_published'];
$price = $_POST['price'];
$database->update($book_id, $book_name, $author, $publisher, $date_published, $price);
header("location:index.php");
}
elseif($action == "delete"){
$book_id = $_GET['book_id'];
$database->delete($book_id);
header("location:index.php");
}
?>