Skip to content

Detail page HTML and CSS, SQL #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified gallerydb.db
Binary file not shown.
24 changes: 18 additions & 6 deletions index.js
Expand Up @@ -76,8 +76,7 @@ router.post('/register', async ctx => {
// encrypt the password
body.password = await bcrypt.hash(body.password, saltRounds)
// insert the user into the db - success!
const sql = `INSERT INTO users(username, password, profilePicture)
VALUES("${body.username}", "${body.password}", "pic_${body.username}");`
const sql = `INSERT INTO users(username, password) VALUES("${body.username}", "${body.password}");`
console.log(sql)
await db.run(sql)
await db.close()
Expand Down Expand Up @@ -236,12 +235,25 @@ router.get('/:id', async ctx => {
if(record === undefined) throw new Error('unrecogised item')
const itemUser = await db.get(`SELECT * FROM users WHERE userID = ${record.userID};`)
// set the data - item info + user info
data.username = itemUser.username
data.picDir = 'ProfilePictures/' + itemUser.profilePicture + '.png'
data.item = record.item
data.name = record.name
data.year = record.year
data.price = record.price
data.imageDir = record.imageDir
data.artist = record.artist
data.medium = record.medium
data.size = record.size
data.itemID = record.itemID
data.sDescription = record.sDescription
data.lDescription = record.lDescription

data.imageDir1 = record.imageDir1
data.imageDir2 = record.imageDir2
data.imageDir3 = record.imageDir3
data.imageDir4 = record.imageDir4
data.imageDir5 = record.imageDir5


data.username = itemUser.username
data.picDir = 'ProfilePictures/' + itemUser.profilePicture + '.png'
await ctx.render('itemDetails', data)
} catch(err) {
console.error(err.message)
Expand Down
21 changes: 21 additions & 0 deletions node_modules/@types/events/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@types/events/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/@types/events/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions node_modules/@types/events/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/@types/formidable/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@types/formidable/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions node_modules/@types/formidable/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions node_modules/@types/formidable/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/@types/node/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@types/node/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.