I'm unsure how to word the title please edit it as necessary. The problem I'm having is than in my server code a database query is made to determine if the account name is a dupe, if it is a message is returned with the template:
con.query('SELECT * FROM Users WHERE username = ?', [username], async (err, results) => {
if (err) {
return res.render("register.ejs", {
message: "Error"
})
}
if (results.length > 0) {
return res.render("register.ejs", {
message: "Username taken"
})
}
})
This message is then meant to be "added" to the html in my ejs file so the user can see it is taken. I can't seem to get this to work. Ejs file:
<% if (message) { %>
<h3><%= message %></h3>
<% } %>
Also, the code itself does work as the website won't let me add a duplicate user, the message just won't show. edit: The actual error seems to be that "message is not defined" on the ejs file.