php-提交表单不会停留在同一页面上

这是我的表格:

    <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>

在我的网站上并按提交(在xampp中)时,我收到一条错误消息,指出

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

我对使用php,css和javascript进行编码有些陌生,但是我一直在努力寻找解决方案,已有2天了,但我一直没有提出任何建议.

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

如果有人可以帮助,那就太好了!谢谢阅读.

解决方法:

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

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

或者使用$_SERVER [‘PHP_SELF’]:

<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
上一篇:Xampp 1.7.4和PHP 5.3.5(不建议使用的警告)


下一篇:无法编辑config.inc.php