繁体   English   中英

登录和登录表单问题

[英]login and sign in form problems

我有两种形式(登录/登录)

登录:

<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/ ,页面会完美显示,但是一旦我单击登录按钮..etc,它就会转到第一个链接。

这两个链接都显示相同的页面,但是我该如何做才能使其不显示

User_login=&user_password=&button等。

有任何想法吗?

您的表单需要一个METHODACTION属性集。

方法应为POST

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

如果要隐藏数据以免在URL中追加,请在html表单中定义POST方法。

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

文档 -

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

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

当表单是幂等时(即不引起任何副作用),应使用“ get”方法。 许多数据库搜索没有明显的副作用,因此是“ get”方法的理想应用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM