Useofundefinedconstantname-assumednamein ...... Code: functionadd_books () {include_once (& quot; class_books.php & quot;); contains the library class if ($ _ POST [& quot; submit & quot;] & quot; add & quo 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"]);