SHARE
TWEET

Untitled

a guest Apr 2nd, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Register
  2.  
  3. app.post('/register', (req,res) => {
  4.   let username = req.body.username
  5.   let password = req.body.password
  6.  
  7.   db.one('INSERT INTO userinfo (username,password) VALUES($1,$2) RETURNING userid;',[username,password])
  8.   res.render('login', {messageA: 'Thank you for registering! Please login below.'})
  9. })
  10.  
  11.  
  12. // Login
  13.  
  14. app.post('/login', (req,res) => {
  15.   let username = req.body.username
  16.   let password = req.body.password
  17.   db.one('SELECT * FROM userinfo WHERE username = $1 AND password = $2', [username, password])
  18.   .then((user) => {
  19.     res.redirect('/index')
  20.   }).catch(error => {
  21.     res.render('login', {message: 'The User Name or Password is incorrect. Please try again!'})
  22.   })
  23. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top