Useofundefinedconstantname-assumed 'name' in ...... The code is as follows: functionadd_books () {include_once (& quot; class_books.php & quot;); Use of undefined constant name-assumed 'name' in ...... The code is as follows:
Function add_books (){
Include_once ("class_books.php"); // contains the library class
If ($ _ POST ["submit"] = "Add "){
If ($ _ POST ["add_book_name"] = "" | $ _ POST ["add_book_price"] = "" | $ _ POST ["add_book_author"] = "") {
Echo "failed to add. please complete the Information
";
Echo "retry ";
}
Else {
$ B = new books;
$ B->__ set (name, $ _ POST ["add_book_name"]);
$ B->__ set (price, $ _ POST ["add_book_price"]);
$ B->__ set (author, $ _ POST ["add_book_author"]);
$ B-> add ();
Echo "book $ _ POST [book_name] added successfully!
";
}
}
}
The red letter indicates the field name of the table in the database.
------ Solution --------------------
PHP code
$ B->__ set (name, $ _ POST ["add_book_name"]); $ B->__ set (price, $ _ POST ["add_book_price"]); $ B->__ set (author, $ _ POST ["add_book_author"]);