Fill in all the required fields. I press ADD RECORD (after which the values should be entered into the table in the database), but nothing happens when I press the ADD RECORD button.
I came to the conclusion that the request is simply not executed. What could be the error?
if(isset($_POST['author']) && isset($_POST['title']) && isset($_POST['category']) && isset($_POST['year']) && isset($_POST['isbn'])) { $stmt->bindParam(':author', $author); $stmt->bindParam(':title', $title); $stmt->bindParam(':category', $category); $stmt->bindParam(':year', $year); $stmt->bindParam(':isbn', $isbn); /*$author = $_POST['author']; $title = $_POST['title']; $category =$_POST['category']; $year = $_POST['year']; $isbn = $_POST['isbn'];*/ // Не знаю нужна ли эта часть кода $stmt = $pdo->prepare("INSERT INTO classics (author,title,category,year,isbn) VALUES(:author,:title,:category,:year,:isbn)"); $stmt->execute(); }
bindParam
must be afterprepare
. but before that, of course, variables should be defined. if you are wondering if this part of the code is needed, then I have bad news for you))) - toxxxa