title: Unable to display error message in view using ejs templates
body: <hr>
  
  <p>I am new to node.js. I am unable to display error messages in view using ejs templates.I want to display <strong>This user already exists</strong>.Here is my codes :</p>
  
  <p>node.js</p>
  
  <pre><code>router.post('/signup', (req, res) =&gt; {
  
      var username = req.body.username;
      var email = req.body.email;
      var password = req.body.password;
      let err_msg = '';
  
      db.query('SELECT * FROM user_data WHERE username = ? and email = ?',  [username,email],(err,rows) =&gt; {
  
          if(err) 
          {
              err_msg = "Some error occured , plz register again.";
              return res.render('signup', { err_msg: err_msg } );
          }
  
          if (!rows.length)
          {
              db.query('INSERT INTO `user_data`(`username`,`email`,`password`) VAlUES (?, ?, ?)', [username,email,password], (err, results) =&gt; {
          return res.redirect('login'); 
          });
  
          }
          else
          {
              err_msg = "This user already exists.";
              return res.render('signup', { err_msg: err_msg } );
          }
      });
  });
  </code></pre>
  
  <hr>
  
  <p>HTML Code</p>
  
  <pre><code>&lt;div class="alert alert-danger" role="alert"&gt;&lt;%= err_msg %&gt;&lt;/div&gt;
  </code></pre>