我已經創建了引導表單,但它不會連接到數據庫。填寫表格後,它給我一個未定義的索引錯誤。我不知道該怎麼做。你可以幫我嗎?我很迷茫。如何將引導表單連接到數據庫
<form name="input" method="post" action="addtodatabase.php">
<form>
<div class="form-group">
<label for="Book_Number">Book Number</label>
<input type="text" class="form-control" id="Book_Number" placeholder="Enter Book Number">
</div>
<div class="form-group">
<label for="Book_Title">Book Title</label>
<input type="text" class="form-control" id="Book_Title" placeholder="Enter Book Title">
</div>
<div class="form-group">
<label for="Book_Description">Book Description</label>
<input type="text" class="form-control" id="Book_Description" placeholder="Enter Book Description">
</div>
<div class="form-group">
<label for="Author">Author</label>
<input type="text" class="form-control" id="Author" placeholder="Enter Author">
</div>
<div class="form-group">
<label for="Publisher">Publisher</label>
<input type="text" class="form-control" id="Publisher" placeholder="Enter Publisher">
</div>
<div class="date">
<label for="Year_Published">Year Published</label>
<input type="date" class="form-control" id="Year_Published" placeholder="Enter Year Published">
</div>
<br>
<input type="submit"> <input type="reset"></center>
</form>
未定義指數誤差是指BOOK_NUMBER等
<?php
$connection = mysql_connect ('localhost','root','');
mysql_select_db('ABC_Library');
$Book_Number = $_POST ['Book_Number'];
$Book_Title = $_POST ['Book_Title'];
$Book_Description= $_POST['Book_Description'];
$Author = $_POST ['Author'];
$Publisher = $_POST['Publisher'];
$Year_Published = $_POST['Year_Published'];
$query =
"INSERT INTO Theology_Books
(Book_Number,Book_Title,Book_Description,Author,Publisher,Year_Published)
values
('$Book_Number','$Book_Title','$Book_Description','$Author','$Publisher','$Y ear_Published')";
$result = mysql_query($query);
Echo "Database Saved";
mysql_close($connection);
?>
中露面顯示確切的錯誤吧。另外,這可能是重複的。 –
您很容易受到[sql注入攻擊](http://bobby-tables.com)的影響,並且您的查詢中的'$ Y ear_Published'不完全有效。 '$ Y'是一個未定義的變量。 –
在$ _POST []數組上執行var_dump()。 – Iain