提交表格不会保留在同一页面上 [英] Submission form won't stay on same page

查看:85
本文介绍了提交表格不会保留在同一页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的表单:

 < form action =#method =post> 
< input type =textsize =25name =firstnameplaceholder =First Namevalue =<?php echo $ fn;?>/>
< input type =textsize =25name =lastnameplaceholder =Last Namevalue =<?php echo $ ln;?>/>
< input type =textsize =25name =usernameplaceholder =Usernamevalue =<?php echo $ un;?>/>
< input type =textsize =25name =emailplaceholder =Emailvalue =<?php echo $ em;?>>
< input type =textsize =25name =email2placeholder =Repeat Emailvalue =<?php echo $ em2;?>/>
< input type =passwordsize =32name =passwordplaceholder =Password/>
< input type =passwordsize =32name =password2placeholder =Repeat Password/>< br />
< input type =submitname =regvalue =注册!/>

< / form>

当我在我的网站上按提交(在xampp中)时,我收到一个错误,指出


未找到对象



在此服务器上找不到请求的网址。
引用页面上的链接似乎是错误的或过时的。如果您认为这是一个服务器错误,请联系网站管理员。



$ b


$ b

错误404



localhost Apache / 2.4.3(Win32)OpenSSL / 1.0.1c PHP / 5.4.7


我对使用php,css和javascript进行编码有点新,但我一直在试图找到解决方案,为期2天,我继续来一无所有。

我只是想让表单在提交或按下登录后留在同一页面!



如果有人能帮忙,那会很棒!谢谢阅读。

解决方案

不指定任何操作会将表单提交到当前页面:

 < form action =method =post> 

或者使用 $ _ SERVER ['PHP_SELF']

 < form action =<?php echo htmlspecialchars($ _ SERVER ['PHP_SELF']);?> ;方法= POST > 


Here is my form:

    <form action="#" method="post">
      <input type="text" size="25" name="firstname" placeholder="First Name" value="<?php echo $fn; ?>"/>
      <input type="text" size="25" name="lastname" 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>

When on my site and pressing submit (in xampp) I get an error stating

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404

localhost Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7

I am somewhat new to coding with php, css, and javascript but I've been trying to find a solution to this for 2 days and I keep coming up with nothing.

I am just trying to get the form to stay on the same page after submitting or pressing sign in!

If anyone could help, that would be great! Thanks for reading.

解决方案

Specifying no action will submit the form to the current page:

<form action="" method="post">

Alternatively use $_SERVER['PHP_SELF']:

<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">

这篇关于提交表格不会保留在同一页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆