>我在程序中有 2 个表单,其中显示第二个表单然后填写,但键入的信息永远不会被 POST 变量捕获。单击第二个表单上的提交后,它总是返回到第一个表单,而无需在第二个表单(注册表单)中执行流程A和B。我需要的是执行流程 A 和 B 并显示成功消息,然后返回到 1st 形式。
请建议为什么它以这种方式运行,我应该改变。
法典:
<body>
<div class="container">
<div id="loginbox">
<form id="loginform" action="" role="form" method="post">
<label>Sign in Screen<br></label>
<label>User id</label>
<input type="text" name="userid" required>
<button id="btn-login" type="submit" class="button">Login</button>
<div class="form-group">
<a href="#" onClick="$('#loginbox').hide(); $('#signupbox').show()">
Sign up here
</a>
</div>
</form>
</div>
<div id="signupbox" style="display:none;" >
<form id="signupform" action="" role="form" method="post">
<label>Sign Up Screen<br></label>
<?php
if (isset($POST['name'])) {
echo "catch after post data<br>";
//process A here........
//process B here........
}
?>
<label>Name</label>
<input type="text" name="name" required>
<button id="btn-signup" type="submit" class="button">Submit</button>
<div class="form-group">
<a href="#" onClick="$('#loginbox').show(); $('#signupbox').hide()">
Sign in here
</a>
</div>
</form>
</div>
</div>
if (isset($POST['name'])) {
应该是
if (isset($_POST['name'])) {
注意:再次,您将在隐藏的div中回显它。因此,要查看回声,您必须转到注册表单。