关于注册表 [英] About Registration form

查看:103
本文介绍了关于注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个表单,该表单接受来自用户的信息并将其存储到数据库中.
但是问题是当我单击刷新按钮或按返回页面时,数据在数据库中重复.

因此,如果有人有解决方案,请帮助我..

I have created a form that accepts information from user and stores it into database.
but problem is that when i click on refresh button or press go back on page, the data duplicates in database.

so if any one has solution please help me out..

推荐答案

有一种称为PRG的模式(POST-重定向-GET).您可以遵循它以避免重复插入.就像将数据发布到服务器,然后将其重定向到相同或不同的页面一样.

如果需要,还有其他方法可以很容易地搜索到.在此处查看讨论. /974850.aspx"target =" _ blank"title =" New Window> ^ ].
There is a pattern called PRG (POST - Redirect - GET). You can follow it to avoid duplicate insertions. Its simply like POST the data to the server, and redirect it to the same or different page.

There are other ways too if you want, which can be easily searched. Have a look at the discussion here[^].


您可以做的是

1.用户按下按钮后,首先检查记录是否已存在于数据库中(基于某些关键字段,例如电子邮件ID)
2.检查结果是否为假.将数据插入DB.
2.当用户单击刷新时,检查将返回true,让用户知道他已经执行了此操作,并且未执行任何操作.

P.S.我也喜欢"Pankaj Nikam"的回答.
what you can do is

1. once user hits the button, first check if the record already exist in DB(based on some key field like email ID)
2. if the check result false. insert the data in DB.
2. when user hits the refresh the check will return true let the user know that he already did it and no action was taken.

P.S. I also liked the answer by "Pankaj Nikam". that is also a good way to go.




将表单/注册数据保存在Button单击事件上.


Hi,

Save your form/registration data on the Button Click Event.
or

If IsPostBack Then
'' save your data to db code here
'' and reset all controls.
End If


这篇关于关于注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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