Applications in ASP How to limit time and again the same form was submitted! ! ! ! Good things
This article describes the application in the prevention of asp users several times during the current session in the same form to submit a simple method. It is mainly composed of four subroutines, in relatively simple applications, you simply place the code contains a direct reference to the document; for those more complex environment, we are given in the article, the final number of suggestions for improvement.
First, the basic process
Now we turn to discuss the four subroutines.
Here we are in the Session object to save the two variables, of which:
⑴ each form a group called the FID corresponding to the unique identifier for the sole use of the value to a counter.
Whenever ⑵ successfully submitted a form to be in a Dictionary object to store its FID.
We use a dedicated process to initialize the above-mentioned data. While the various subroutine must be called after it, but in reality it is only every once during the conversation:
Sub InitializeFID ()
If Not IsObject (Session ( "FIDList")) Then
Set Session ( "FIDList") = Server.CreateObject ( "Scripting.Dictionary")
Session ( "FID") = 0
(B) form a unique identifier generated
The following function GenerateFID () used to generate the only sign the form. The first FID function value plus 1, and then return to it:
Function GenerateFID ()
Session ( "FID") = Session ( "FID") + 1
GenerateFID = Session ( "FID")
(C) The registration form has been submitted
When the form was submitted successfully, in the Dictionary object to register its unique identifier:
Sub RegisterFID ()
strFID = Request ( "FID")
Session ( "FIDlist"). Add strFID, now ()
(D) check whether the repeated submission of form
In a formal deal with the user before submitting the form, it should be in the Dictionary object of the FID to check whether it has been registered. The following CheckFID () function used to complete this work, for example, have been registered, it return FALSE, otherwise return TRUE:
Function CheckFID ()
strFID = Request ( "FID")
CheckFID = not Session ( "FIDlist"). Exists (strFID)
Second, how to use the
There are two places to use the above function, namely to generate a form with the results of treatment. Subroutine has been assumed that the four Forms.inc Add include file, the following code to determine the value according to FID to generate the form or forms to deal with the results of the process it describes ASP is suitable for most applications:
<% Option Explicit%>
<! - # Include file = "forms.inc" ->
<TITLE> form to submit test </ TITLE>
If Request ( "FID") = "" Then
Responsible for generating GenerateForm form, the form should contain a hidden FID, such as:
Sub GenerateForm ()
<Form action = "<% = Request.ServerVariables (" PATH_INFO ")%>" method = GET>
<Input type = hidden name = FID value = "<% = GenerateFID ()%>">
<Input type = text name = "param1" value = "">
<Input type = submit value = "OK">
ProcessForm responsible for the content submitted through the form, but should be in handling the call before CheckFID () to check whether the current form has been submitted, the code categories such as:
Sub ProcessForm ()
If CheckFID () Then
Response.Write "You entered is" & Request.QueryString ( "param1")
Response.Write "This form can only submit once!"
Third, limitations and improvements
Above, we introduced during the current session limit in the same form was submitted by a method many times. In practical applications may need to be improved in many ways, such as:
⑴ ID in the registration form prior to check the legitimacy of the user input data, the data is not lawful user may press the "back" button to return to, in the revised submission of the same form again.
⑵ such restrictions on the form submission only effective during the current session. If such restrictions across multiple sessions, then they would have used to save Cookeis or database of relevant data.
⑶ this method is unsafe. It is only used to prevent misoperation, skilled users can not prevent intentionally submitted the same form several times.
Asp and XML related Articles
- ASP's Internet / Intranet Programming Frequently Asked Questions
- ASP Error 0115 the number of solutions
- How to use Microsoft Access and Active Server Pages encrypt your page
- Html how to add dynamic Form of documents
- Applications in ASP How to limit time and again the same form was submitted! ! ! ! Good things
- XML and ASP combined with the realization of a simple HTML template function
- XMLHTTP crawl garbled data solve the problem
- Filter records using xsl
- XMLHTTP call asynchronous data
- Subtidal imaging in the Web interface, like the Explorer tree directory (cool effects)
- The use of XML data to ASP form filling
- XMLHTTP friends dedicated to learning
- XMLHTTPRequest object with client-side validation
- The third way to the ASP --- XML-based message board
- How to dynamically generated xml document Asp
- Order to use ASP to read and write their own method of XML documents (a)
- Made at any time without refreshing the current server time users landing time, online time, idle time and automatically from the example of
- XMLHTTP to download remote data output to the browser
- Use XMLHTTP to obtain data without refresh.
- Use XMLHTTP to achieve two linked Select
Can't Find What You're Looking For?
Rating: Not yet rated