【问题标题】:Form redirect to same page, but showing that not exist表单重定向到同一页面,但显示不存在
【发布时间】:2020-04-26 23:27:43
【问题描述】:

您好,我的 html 表单有一个非常奇怪的问题。我正在使用 Wordpress,并创建了我的自定义 html 表单。当我提交表单时,它会将我重定向到同一页面 url,但显示该页面不存在。

我的表格:

<form action="" method="post">
                    <div class="form-group">
                        <input type="text" name="name" class="form-control input-text" placeholder="Vaše jméno a příjmení" />
                        <div class="validation"></div>
                    </div>
                    <div class="form-group">
                        <input type="email" class="form-control input-text" name="email" placeholder="Váš e-mail" />
                        <div class="validation"></div>
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control input-text" name="subject" placeholder="Předmět zprávy" />
                        <div class="validation"></div>
                    </div>
                    <div class="form-group">
                        <textarea class="form-control input-text text-area" name="message" rows="5" placeholder="Vaše zpráva pro nás..."></textarea>
                        <div class="validation"></div>
                    </div>

                    <div class="row">
                        <!-- Google reCAPTCHA widget -->
                        <div class="col-lg-8 col-sm-8">
                            <!-- recaptcha here -->
                        </div>
                        <div class="col-lg-4 col-sm-4" style="padding-right: 0; padding-left: 0;">
                            <div class="text-center" style="margin-right: 7px;"><button name="submit" style="width: 135px; height: 75px; padding:0 !important;" type="submit" class="input-btn">Odeslat</button></div>
                        </div>
                    </div>
                </form>

我试图隐藏我所有的 php 代码,也隐藏 google recaptcha,但没有任何效果,问题出在其他地方。我的action也是空的,只是set方法。

出了什么问题,有什么建议吗?

【问题讨论】:

  • “但显示该页面不存在”如 404?还是因为它不接受 POST?
  • 404 错误,我有自定义页面显示 404 错误。我没有使用 Wordpress 中的表单的经验,所以我不确定这样做是否可以
  • 你有没有试过省略 action="" ?
  • action="" 是无效的表单设置。只需省略 action 属性即可。

标签: html wordpress forms


【解决方案1】:

您必须将字段名称 name="name" 更改为其他名称。 有关更多信息,您可以在此处阅读 https://wordpress.stackexchange.com/questions/11749/why-when-i-submit-a-form-in-wordpress-it-loads-a-404-page-though-url-is-correct

【讨论】:

  • 非常感谢,老实说,拯救我的今天
【解决方案2】:

也许问题出在submit 按钮上。

创建表单时,提交按钮也是input

你可以试试

<input type="submit" value="submit" yourtags="yourvalue">

更多数据请参见https://www.w3schools.com/html/html_forms.asp

编辑:如果您尝试将操作发送到同一页面,请省略 action 属性。可能将其留空会导致错误。

【讨论】:

  • 不知道。我只是被教导将其作为输入。那么问题是操作属性还是其他问题
猜你喜欢
  • 1970-01-01
  • 2015-05-06
  • 2015-08-12
  • 2020-03-23
  • 1970-01-01
  • 1970-01-01
  • 2019-09-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多