Skip to content

Commit

Permalink
Update patrons now uses request parameter for id
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonglittle committed Nov 30, 2021
1 parent b3eb570 commit 852442d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion library-express/patrons.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ module.exports = function () {
var mysql = req.app.get('mysql');
console.log(req.body)
var sql = "UPDATE Patrons SET firstName = ?, lastName = ?, registerDate = ?, contactPhone = ?, contactEmail = ?, favoriteTitle = ? WHERE memberID = ?";
var inserts = [req.body.firstName, req.body.lastName, req.body.registerDate, req.body.contactPhone, req.body.contactEmail, req.body.favoriteTitle, req.body.id];
var inserts = [req.body.firstName, req.body.lastName, req.body.registerDate, req.body.contactPhone, req.body.contactEmail, req.body.favoriteTitle, req.params.id];
sql = mysql.pool.query(sql, inserts, function (error, results, fields) {
if (error) {
console.log(JSON.stringify(error));
Expand Down
1 change: 0 additions & 1 deletion library-express/views/update_patrons.handlebars
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<main>
<h1>Update Patron</h1>
<form id="updatePatron" action="/patrons/{{patron.id}}" method="post">
<input type="hidden" id="id" name="id" value={{patron.id}}>
<p><label for="firstName">First Name:</label><br>
<input type="text" name="firstName" value="{{patron.firstName}}" required>
</p>
Expand Down

0 comments on commit 852442d

Please sign in to comment.