HTML Form在提交后发布两次 [英] HTML Form posts twice after submitting

查看:209
本文介绍了HTML Form在提交后发布两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为解决方案进行编辑:



我仍然不知道为什么它会进行重复输入,但是暂时我

我在窗体中添加了一个UID令牌,生成一个MD5并将其与数据库条目一起存储。该脚本会检查是否已经存在条目。如果确实如此,则会传递条目ID,如果不是,则添加新条目,然后传递该ID作为最终确认消息。



即使是幸运的是,所以我能够抓住它做到这一点。如果这是两个不同的UID,那么我可能有问题,哈哈。



我想要点PeeHaa,因为如果其他人发现这个问题,我想要其他人们也知道Post,Redirect和Get是一种很好的编码习惯。 (发布到您的插入脚本,从页面重定向到确认页面,并使用GET来显示值)。



Previous content:

好的,这是非常基本的。



我知道这里已经有人问过这么多次,但没有任何现有的问题与我的问题有关。



基本的HTML表单。没有花哨的jQuery或任何东西。

 < form id =attendee_confirmclass =regformmethod =postaction = http://url.com/wip/events/register/?\"> 
< input name =attendee [0] [first_name]value =Bruce>
< input name =attendee [0] [last_name]value =Wayne>


< input type =hiddenname =reg_formvalue =true>
< input type =hiddenname =questionsvalue =true>
< input type =hiddenname =actionvalue =done_confirming>
< input type =hiddenname =event_idvalue =1>

< input type =submitname =mySubmitid =mySubmitvalue =确认>
< input type =buttonvalue =& lt; - BACKonclick =history.go(-1); return false;>

< / form>

为什么我的表单发布了两次数据?我真的不明白这一点。



这是一个确认表单。填写完第一个表单后,用户会被带到这里,只是为了确认名称。



第一个表单工作正常,并提供相应的信息。第二个应该确认并发送电子邮件/进程。



表单发布两次,我只看到第二次尝试的输出。因此,如果我尝试添加会话令牌捕捉到表单以尝试捕获重复的条目,则第一个尝试允许通过,但用户只能看到第二个catch。



这可能是服务器问题吗?我的服务器正在运行ModSecure(最近一直让我失望),而且我非常沮丧。当我不应该时,我会为我的活动获得双倍的入住...

编辑信息

这发生在所有浏览器上,所以它不是浏览器特定的。



我也尝试将捕获脚本设置为在收到信息后重定向过程,但正如我所提到的,数据首先被一些看不见的东西发送,而用户看到的输出实际上是第二个数据。不是第一套。一切仍然翻倍。 Owf ..



服务器日志很糟糕。它发生在一篇文章中。我将仔细检查可能运行两次的脚本..... 解决方案

我仍然不知道为什么它是做了双重入口,但暂时我做了一些攻击。

我在窗体中添加了一个UID令牌,生成了一个MD5并将其存储在数据库中条目。该脚本会检查是否已经存在条目。如果确实如此,则会传递条目ID,如果不是,则添加新条目,然后传递该ID作为最终确认消息。



即使是幸运的是,所以我能够抓住它做到这一点。如果这是两个不同的UID,那么我可能有问题,哈哈。



我想要点PeeHaa,因为如果其他人发现这个问题,我想要其他人们也知道Post,Redirect和Get是一种很好的编码习惯。 (发布到您的插入脚本,从页面重定向到确认页面,并使用GET获取值显示)。


Edit for solution:

I still don't know why it's doing the double entry, but for the time being I've done some hacks.

I added a UID token to the form, generated an MD5 and stored it with the DB entry. The script does a check to see if entry already exists or not. If it does, it passes off the entry ID, if not it adds a new one, then passes off the ID for final confirmation message.

The form was doubling even the UID luckily, so I was able to catch it doing that. If it was two different UID's, then I may have had problems, haha.

I'd like points goto PeeHaa, because if anyone else finds this question, I want other people to also know that Post, Redirect and Get is a good coding practice. (Post to your inserting script, redirect away from the page to a confirmation page, and use GET to get values to show).

Previous content:

OK, this is pretty basic.

I know it's been asked a bazillion times here already, but none of the existing questions are pertinent to my problem.

Basic HTML form. No fancy jQuery or anything.

<form id="attendee_confirm" class="regform" method="post" action="http://url.com/wip/events/register/?">
<input name="attendee[0][first_name]" value="Bruce">  
<input name="attendee[0][last_name]" value="Wayne">


<input type="hidden" name="reg_form" value="true">
<input type="hidden" name="questions" value="true">
<input type="hidden" name="action" value="done_confirming">
<input type="hidden" name="event_id" value="1">

<input type="submit" name="mySubmit" id="mySubmit" value="Confirmed"> 
<input type="button" value=" &lt;-- BACK " onclick="history.go(-1);return false;">

</form>

WHY is my form posting it's data twice?? I really don't understand this.

This is a confirmation form. A user is brought here after filling out the first form, just to confirm the names.

The first form works fine, and brings over the appropriate information. The second one is supposed to confirm and send the email/process.

The form posts twice, and I only ever see the output from the 2nd attempt. I cannot get any output from the first one.

Because of this, if I try adding Session Token "catches" to the form to try and catch duplicate entries, the first try is allowed through, but the user only sees the second catch.

Is this perhaps a server problem? My server is running ModSecure (Which has been pissing me off lately), and I'm really frustrated. I'm getting double occupancy for my events when I shouldn't...

Edit info:

This happens on all browsers, so it is not browser specific.

I've also tried setting the capture script to redirect after receiving information to process, but as I mentioned, the data is being sent by some invisible thing first, and the output seen by the user is actually the second data. Not the first set. Everything is still doubled. Owf..

The server logs were a bust. It's happening in one post. I'm going to double check scripts that might run twice.....

解决方案

I still don't know why it's doing the double entry, but for the time being I've done some hacks.

I added a UID token to the form, generated an MD5 and stored it with the DB entry. The script does a check to see if entry already exists or not. If it does, it passes off the entry ID, if not it adds a new one, then passes off the ID for final confirmation message.

The form was doubling even the UID luckily, so I was able to catch it doing that. If it was two different UID's, then I may have had problems, haha.

I'd like points goto PeeHaa, because if anyone else finds this question, I want other people to also know that Post, Redirect and Get is a good coding practice. (Post to your inserting script, redirect away from the page to a confirmation page, and use GET to get values to show).

这篇关于HTML Form在提交后发布两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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