gpt4 book ai didi

HTML 表单未在 Express 中发送数据

转载 作者:太空宇宙 更新时间:2023-11-03 22:41:13 25 4
gpt4 key购买 nike

我有以下 HTML 表单:

    <form method="post" id="registration-form" action="/register"> 
<div class="form-group">
<label for="UsernameRegistration">Username:</label>
<input type="text" class="form-control" id="UsernameRegistration">
</div>
<div class="form-group">
<label for="PasswordRegistration">Password:</label>
<input type="password" class="form-control" id="PasswordRegistration">
</div>
<div class="form-group">
<label for="ConfirmPasswordRegistration">Confirm Password:</label>
<input type="password" class="form-control" id="ConfirmPasswordRegistration">
</div>
<input type="submit" class="form-control" />
</form>

/register 端点如下所示:

router.post('/register', function(req, res, next) {
console.log(req);
});

在req.query和req.body中,没有数据。我做错了什么?

最佳答案

<input type="password" class="form-control" id="PasswordRegistration">

此处未指定属性name。应该是这样的

<input type="password" name="password" class="form-control" id="PasswordRegistration">

关于HTML 表单未在 Express 中发送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40540708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com