-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert.php
29 lines (26 loc) · 990 Bytes
/
insert.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
<?php
session_start();
include("db.php");
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$book_id = $_POST["book_id"];
if(!empty($_FILES['poster_image']['name'])) {
$img_name = $_FILES['poster_image']['name'];
$image = $_FILES['poster_image']['tmp_name'];
$imgData = addslashes(file_get_contents($image));
}
$title = $_POST["title"];
$genre = $_POST["genre"];
$publication_date = $_POST["publication_date"];
$author = $_POST["author"];
$ratings = $_POST["ratings"];
$category = $_POST["category"];
$sql = "INSERT INTO book (book_id, poster_image, title, genre, publication_date, author, ratings, category) VALUES ('$book_id', '$imgData', '$title', '$genre', '$publication_date', '$author', '$ratings', '$category')";
if ($conn->query($sql) === TRUE) {
header('Location:addnewbook.php');
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
?>