【发布时间】:2022-01-20 21:09:46
【问题描述】:
我正在尝试查看连接的数据库是否有一封与用户发布的电子邮件相匹配的电子邮件:
app.post("/forgot_password", (req, res, next) => {
try {
const { emailId } = req.body;
db.query("SELECT * FROM user WHERE email = ?", async (error, results) => {
if (error) {
console.log(error);
}
if (emailId != results) {
//Change to pop up saying incorrect email
res.render("forgot_password")
return
}
})
} catch (error) {
console.log(error)
}
})
如何检查“email”列中的任何数据是否与此处发布的“emailId”常量匹配:
<form action="" method="POST">
<label for="email">Email</label>
<input type="email" name="emaild" id="email">
<br>
<input type="submit" value="submit">
</form>
【问题讨论】:
标签: javascript mysql node.js