SQL data not displaying in EJS page

I want to display data of a student in an ejs page using the key value entered in the login js page. The query is getting displayed in git bash but nothing is being displayed in the ejs page.


var express = require("express");
var bodyparser = require("body-parser");
var request = require("request");
var createError = require('http-errors');
var db=require('./dbms');

const app = express();

app.set("view engine","ejs")


let nwfname="";
let nwlname="";
let nwemail="";
let nwmob="";

app.get("/",function(req, res){
app.post("/", function(req, res){
    var mreg = req.body.regno;
    var msuin = req.body.suin;

    var sql = `SELECT * FROM rba1dr18 WHERE REG_NO="${mreg}" AND EXCL_ROLL="${msuin}"`;
    db.query(sql, function(err, result) {
    console.log("SQL run successfully...")
    res.render('rbu_form_save', {title: 'My Query Data', data: result});


app.post("/rbu_form_save", function(req, res){

app.use(function(req, res, next) {
  // error handler
app.use(function(err, req, res, next) {
    // set locals, only providing error in development
    res.locals.message = err.message;
    res.locals.error = req.app.get('env') === 'development' ? err : {};
    // render the error page

app.listen(3000, function(){
    console.log("Server is Connected");

rbu_form_save.ejs :point_down:

<!doctype html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Untitled Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="css/nwstyle.css" rel="stylesheet">


<div class="row" style="background-color: lightblue" >
        <div class="col-sm-4 col-lg-3 px-3">
          <img src="images/rbulogo.jpg" alt="No Logo" height="40px" width="40px">
        <div class="col-sm-4 mt-2 col-lg-7">
            <h2 class="brb display-9 text-left">RABINDRA BHARATI UNIVERSITY</h2>

    <div class="row sm-2" style="background-color: dodgerblue; height: 30px;">
       <div class="col-sm-3 mt-1 blink offset-9">
          <span style="font-weight: bolder; font-size: small;">Helpline Number 9830620582</span>

<div class="row mb-lg-5">

<main class="container-sm ">

<div class="row ">
  <div class="col-lg-2 offset-lg-4" style="color:blue;">Registration No.</div>
  <div class="w-30" style="background-color: #eee;"><%=data.REG_NO%></div>
<div class="row ">
  <div class="col-lg-2 offset-lg-4" style="color:blue;">Student Id.</div>
  <div class="w-30"><%=data.EXCL_ROLL%></div>

<div class="row ">
  <div class="col-lg-2 offset-lg-4" style="color:blue;">Name</div>a
  <div class="w-30"><%=data.S_NAME%></div>

<form action="/rbu_form_save" method="post">	
   <button class="btn btn-sm btn-primary offset-4" onclick="rbu-reg-form.html" type="submit">Back</button>
<p class="mt-5 mb-3 text-muted">&copy; 2017–2021</p>


dbms.js :point_down:

var mysql = require('mysql');
var conn = mysql.createConnection({
  host: 'localhost', // Replace with your host name
  user: 'root',      // Replace with your database username
  password: '',      // Replace with your database password
  database: 'anin' // // Replace with your database Name
conn.connect(function(err) {
  if (err) throw err;
  console.log('Database is connected successfully !');
module.exports = conn;

Screenshot 2022-07-03 235224

The above image is a portion of the table. I want to display the data of that student only according to the key fields ‘REG_NO’ and ‘EXCL_ROLL’

I want to the display the data of that student in this format:

Registration Number(‘REG_NO’): XXXXXXX



This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.