use*_*365 0 html node.js express
我在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>
Run Code Online (Sandbox Code Playgroud)
该/register端点如下所示:
router.post('/register', function(req, res, next) {
console.log(req);
});
Run Code Online (Sandbox Code Playgroud)
在req.query和req.body中,没有数据.我究竟做错了什么?
小智 5
<input type="password" class="form-control" id="PasswordRegistration">
Run Code Online (Sandbox Code Playgroud)
这里没有指定属性名称.应该是这样的
<input type="password" name="password" class="form-control" id="PasswordRegistration">
Run Code Online (Sandbox Code Playgroud)