Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
user login database connection

I want my code only admin to be able to login. It should throw an error when other users enter.

const path = require('path');

const express = require('express');

const router = express.Router();


const baglanti=require('../util/vt_baglanti');



router.get('/login', (req,res,next) => {

  baglanti.getConnection(function(err) {

    if (err) throw err;

    baglanti.query("SELECT * FROM sehir", function (err, result, fields) {

      if (err) throw err;

      res.render('login', {

        sayfa_basligi:'Giriş',

        path:'/admin/login',

        sehir:result

      });

    });

  });

})

router.post('/login', (req,res,next) => {
  
  baglanti.getConnection(function(err) {

    if (err) throw err;

  console.log(req.body.kullaniciadi);

    var sql = "SELECT * FROM kullanici WHERE kullaniciadi='"+req.body.kullaniciadi+"' AND
 
sifre='"+req.body.sifre+"'";

    baglanti.query(sql, function (err, result) {

      if (err) throw err;

    });

  });

res.redirect('/');


});

//module.exports=router;

exports.routes=router;
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!