<div class="container__form container--signup"> <form action="{{ url_for('auth.login') }}" class="form" id="form1" method="POST"> <h2 class="form__title">注册</h2> <input type="text" placeholder="用户名账号" class="input" name="username" /> <input type="email" placeholder="邮箱" class="input" name="email"/> <input type="password" placeholder="密码" class="input" name="password"/> <button class="btn" type="submit" name="register_submit" onclick="submitForm()">注册</button> </form> </div> <!-- Sign In --> <div class="container__form container--signin"> <form action="{{ url_for('auth.login') }}" class="form" id="form2" method="POST"> <h2 class="form__title">登录</h2> <input type="email" placeholder="邮箱" class="input" name="email"/> <input type="password" placeholder="密码" class="input" name="password"/> <a href="#" class="link">忘记密码?</a> <button class="btn" type="submit" name="login_submit" onclick="submitForm()">登录</button> </form> </div>为什么提交后表单中没有“register_submit”或“login_submit”
时间: 2023-06-26 10:09:08 浏览: 166
这是因为在表单中没有设置提交按钮的值。如果您想要在提交表单时标识表单类型,可以在提交按钮上添加一个隐藏的 input 元素,并将其值设置为 "register_submit" 或 "login_submit"。例如:
```
<button class="btn" type="submit" onclick="submitForm()">注册</button>
<input type="hidden" name="register_submit" value="register_submit">
```
```
<button class="btn" type="submit" onclick="submitForm()">登录</button>
<input type="hidden" name="login_submit" value="login_submit">
```
这样,当用户提交表单时,服务器就能正确识别表单类型了。
阅读全文