The mysql table clearly has data, why does it return an empty array when extracting the data?

ask the elders, want to extract the user name and password from the mysql to verify the login, the mysql table clearly has data, but the request is to return an empty array, check the database statement can not see the problem, I would like to ask the seniors, where am I wrong? thank you!

Code

module.exports = ()=>{
 var router = express.Router();
 //
 router.get("/",(req,res)=>{
   res.render("admin/login.ejs",{})
   // res.send("arrive login.js")

 })

//
 router.post("/",(req,res)=>{
   console.log(req.body)
   var username = req.body.username;
   var password = commom.md5(req.body.password+commom.MD5_SUFFIX);
   //
   db.query(`SELECT * FROM admin_table WHERE username="${username}"`,(err,data)=>{
     console.log(data)
     if(err){
       res.status(500).send("database error").end();
     }else{
       if(data.length == 0){
         res.status(400).send("no admin").end();
       }else{
         if(data[0].password = password){
           //IDsessionadmin_id
           req.session[admin_id] = data[0].ID;
           res.redirect("/admin");
         }else{
           res.status(400).send("invalid password").end()
         }
       }
     }
   })

 })

PS: server

written using express

! [picture upload.]


I don't know express . Idea: print your sql query statement, and then execute it in the database to see the results


user name and password may be wrong

Menu