我写了一个代码,我使用Boostrap进行2下拉:登录并注册。完成输入字段后,信息不会发送...并且提交按钮会将我重定向到index.php?username ="什么是用户名字段"& password ="密码输入& #34;
我想将数据发送到信息index.php?tab = SignIn ...可能有什么问题?
<ul class="nav navbar-nav nav pull-right">
<li class="animated dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-lock fa-2x"></i><br /> Register <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<?php
@$_SESSION['username2'] = $_POST['username'];
@$_SESSION['email'] = $_POST['email'];
@$_SESSION['password'] = $_POST['password'];
?>
<form class="form" id="formLogin" action="index.php?tab=SignUp">
<li><div class="form-group">
<input type="text" name="username" id="username" class="form-control" placeholder="Username" value="<?= $_SESSION['username2'] ?>" required/>
</div></li>
<li><div class="form-group">
<input type="email" name="email" id="email" class="form-control" placeholder="E-Mail Address" value="<?= $_SESSION['email'] ?>" required/>
</div></li>
<li><div class="form-group">
<input type="password" name="password" id="password" class="form-control" placeholder="Password" value="<?= $_SESSION['password'] ?>" required/>
</div></li>
<li class="divider"></li>
<input type="submit" name="register" class="btn btn-success" value="Register" tabindex="7">
</form>
</ul>
</li>
</ul>
答案 0 :(得分:1)
替换此
<form class="form" id="formLogin" action="index.php?tab=SignUp">
用这个
<form class="form" id="formLogin" action="index.php" method="post">
<input type="hidden" name="tab" value="SingUp" />
并在你的index.php获取标签参数$ _POST [&#39; tab&#39;]
答案 1 :(得分:0)
更改
<form class="form" id="formLogin" action="index.php?tab=SignUp">
到
<form class="form" id="formLogin" action="index.php?tab=SignUp" method="post">
答案 2 :(得分:0)
不。每次只调用index.php。没有后缀到网址。如果你想要一个特殊的值,那么在表单中创建一个隐藏元素,并设置值,这样第二次用户点击index.html时,该值将填充...
<?php
@$_SESSION['username2'] = $_POST['username'];
@$_SESSION['tab'] = $_POST['tab']; // set in the original form in a hidden field.
@$_SESSION['email'] = $_POST['email'];
@$_SESSION['password'] = $_POST['password'];
?>
沿线的某个地方做一个测试if ($_POST['tab'] == "SignUp")
然后做任何事情。如果$ _POST ['tab'] isnt = SignUp,那么你知道它第一次到那个页面....
保持简单。少即是多! (哎呀..我是Gabriele Pieretti的帖子的副本)我赞成GP! THX。