php - How do you connect bootstrap form to database -


i have created bootstrap form ,but won't connect database. after filling forms, gives me undefined index error. have no idea do. can me? i'm lost.

<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> 

the undefined index error refers book_number etc.

 <?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 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); ?> 

with forms send data next page inputs need have name attribute. try changing id = 'book_number' name = 'book_number'


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -