I'm doing this for an assessment and I'm nearly done but every time I try updating or editing my database with PHP code it gives the Undefined variable error
I've tried isolating the code that it says is causing the error and fixing it but whatever I do it never works
HTML:
<form id = "add_books_form" name = "new_book" method = "post" action = "book_processings.php">
<div id = "inputs"><label>ISBN </label><input id = "elements" type = "text" maxlength = "30" name = "ISBN" required/><br></div>
<div id = "inputs"><label>Title </label><input id = "elements" type = "text" maxlength = "100" name = "Title" required/><br></div>
<div id = "inputs"><label>Replacement Cost $ </label><input id = "elements" type = "number" value = "0.00" step = "0.10" min = "0" max = "99.99" name = "ReplacementCost" required/><br></div>
<div id = "inputs"><label>Adult Theme </label><select id = "elements" name = "adult_theme">
<option value = "Y">Yes</option>
<option value = "N">No</option>
</select><br></div>
<div id = "inputs"><label>Category </label><select id = "elements" name = 'category'>
<?php
while($all_category_rec = mysqli_fetch_assoc($all_category_qrun)){
echo"<option value = '".$all_category_rec['CategoryID']."'>".$all_category_rec['Category']."</option>";
}
?>
</select><br></div>
<div id = "inputs"><label>Author </label><select id = "elements" name = 'author'>
<?php
while($all_authors_rec = mysqli_fetch_assoc($all_authors_qrun)){
echo"<option value = '".$all_authors_rec['AuthorID']."'>".$all_authors_rec['FirstName']." ".$all_authors_rec['LastName']."</option>";
}
?>
</select><br></div>
<div id = "inputs"><label>Publisher </label><select id = "elements" name = 'publisher'>
<?php
while($all_publishers_rec = mysqli_fetch_assoc($all_publishers_qrun)){
echo"<option value = '".$all_publishers_rec['PublisherID']."'>".$all_publishers_rec['PublisherName']."</option>";
}
?>
</select><br></div>
<div id = "inputs"><label>Published Year </label><input id = "elements" type = "number" step = "1" max = "2025" min = "1400" value = "2019" name = "YearOfPublication" required/><br></div>
<input id = "button" type = "submit" name = "submit" value = "Add Book"/>
</form>
PHP:
if($_POST['submit'] == 'Add Book'){
$add_book_query = "INSERT INTO books(ISBN, Title, ReplacementCost, AdultContent, Category, AuthorID, YearOfPublication , PublisherID)
VALUES('$ISBN', '$Title', '$ReplacementCost', '$AdultContent', '$CategoryID', '$AuthorID', '$YearOfPublication', '$PublisherID')";
$add_book_qrun = mysqli_query($dbcon, $add_book_query);
if(!$add_book_qrun){
echo"<h3>Data was not entered.</h3>";
}else{
echo"<h3>Data was successfuly enetered.</h3>";
}
echo"<form id = 'proc' name = 'go_back' method = 'post' action = 'add_book.php'>";
echo"<input id = 'button' type = 'submit' name = 'submit2' value = 'Go Back'/>";
echo"</form>";
}
for this query, I am expecting it to add the details I have entered into my database but instead, I get unidentified variable for all my values