Viewing file: add_book.php (716 B) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php // Connect to the database (you should replace these with your own database credentials) include 'connect.php'; // Retrieve user input from the form $title = $_POST['title']; $author = $_POST['author']; $year = $_POST['year']; $isbn = $_POST['isbn']; $rate = $_POST['rate']; // Insert the book into the database $sql = "INSERT INTO books (title, author, publication_year, ISBN,rate) VALUES ('$title','$author','$year','$isbn','$rate')"; $stmt = $db->prepare($sql); $stmt->bind_param("ssis", $title, $author, $year, $isbn);
if ($stmt->execute()) { echo "Book added successfully."; } else { echo "Error: " . $stmt->error; }
$stmt->close(); $db->close(); ?> <?php
header("Location: viewbooks.php");
?>
|