登录并登录表单问题

时间:2013-06-25 19:39:24

标签: php html5 pdo xampp

我有两种表格(登录/登录)

登录:

<form action="#" method="post">
  <input type="text" size="25" name="fname" placeholder="First Name" value="<?php echo $fn; ?>"/>
  <input type="text" size="25" name="lname" placeholder="Last Name" value="<?php echo $ln; ?>"/>
  <input type="text" size="25" name="username" placeholder="Username" value="<?php echo $un; ?>"/>
  <input type="text" size="25" name="email" placeholder="Email" value="<?php echo $em; ?>">
  <input type="text" size="25" name="email2" placeholder="Repeat Email" value="<?php echo $em2; ?>"/>
  <input type="password" size="32" name="password" placeholder="Password"/>
  <input type="password" size="32" name="password2" placeholder="Repeat Password"/><br />
  <input type="submit" name="reg" value="Sign Up!"/>
</form>

登录:

<form>
<center><input type ="text" size="25" name="User_login" id="user_login" placeholder="username"/>
<input type ="password" size="25" name="user_password" id="user_password" placeholder="password"/><br />
<input type ="submit" name="button" id="button" value="login to your account!"/></center>
</form>

按下任一表格上的登录按钮或登录按钮后,我会回到同一页面(这就是我想要的),但这是我的地址栏中显示的内容:

http:// localhost/sites/socialnetwork/User_login=&user_password=&button=login+to+your+account%21#

我希望它是http:// localhost /sites/socialnetwork/#

在地址栏中输入http:// localhost/ sites/ socialnetwork/时,页面会完美显示,但只要我点击登录按钮,就会转到第一个链接。

两个链接都显示相同的页面,但我如何制作它以使其不显示

User_login=&user_password=&button等。

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

您的表单需要设置METHODACTION属性。

方法应该是POST

例如,

ACTION应该是“some-page-name.php”。

答案 1 :(得分:0)

如果要隐藏数据不附加在网址中,请在html表单中定义POST方法。

默认表单是通过GET方法提交的,因此您需要在您的情况下明确定义POST

来自Docs -

FORM元素的method属性指定用于将表单发送到处理代理程序的HTTP方法。此属性可能包含两个值:

  • get:使用HTTP“get”方法,将表单数据集附加到 action属性指定的URI(带问号(“?”)为 分隔符)并将此新URI发送给处理代理。
  • post:使用HTTP“post”方法,表单数据集包含在 表格的正文并发送给处理代理。

当表单是幂等的时候(即,不会产生副作用),应该使用“get”方法。许多数据库搜索没有明显的副作用,并为“获取”方法提供了理想的应用程序。