?
Solved

Form question

Posted on 2003-03-05
11
Medium Priority
?
301 Views
Last Modified: 2013-12-24
I have a form that after the user fills out the form then hits submit goes to a asp page.  At this point the user can check the information they filled out and if alls correct they hit the submit button.The users information then goes into the database and gives them a confirmation page.  Now for my questions.  How to I keep the user from hitting the back button and submitting it again. More importantly how do I not show the information in case the user leaves a public computer and anther users walks up and hit's the back button and see's all the user's private inforamtion.  This site was written using Frontpage 2002.  
0
Comment
Question by:jamesjs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 4

Accepted Solution

by:
CRagsdell earned 400 total points
ID: 8076276
You could use code to check to see if the form has been submitted, and simply not show the form if it has already been submitted. Set a session variable if the form gets processed, then check it to see if you need to show the form.

On the page where the original form is shown, add the following code:

<%

If Session("Form1Processed") = 1 Then

Response.Write "The form has already been submitted"

Else

Response.Write "<form method=""post"" action=""post1.asp"" name=""Form1"">"

Response.Write "<input type=""Text"" size=""20"" name="T1">

Response.Write "<input type=""submit"" value=""Submit"" name="B1">

End If

%>

On the page where the form recap is shown (post1.asp), use code to see if the form has been processed and to set the session value to show the first form has been submitted:

<%

Session("Form1Processed") = 1

If Session("Form2Processed") = 1 Then

Response.Write "The form has already been submitted"

Else

Response.Write "Here is what you entered..."

' Add the code to grab the values entered in the first form and add them to the appropriate form fields to give the user one last chance to edit the info before submitting it...

Response.Write "<form method=""post"" action=""post2.asp"" name=""Form2"">"

Response.Write "<input type=""Text"" size=""20"" value = " & Request.Form("T1") & " name="T1">

Response.Write "<input type=""submit"" value=""Submit"" name="B1">

End If

%>

On the page post2.asp, add the following line of code:

<%

Session("Form2Processed") = 1

%>

CR
0
 
LVL 14

Expert Comment

by:hhammash
ID: 8078813
Hi,

All what you need is in the body tag of all your forms put:

Your body tag is originally <body>
Just insert the onLoad part after the body to look like this:

When the user hits back button.  He/she will find the form blank.

<body onLoad="document.form1.reset();">

Regards
hhammash
0
 
LVL 14

Expert Comment

by:hhammash
ID: 8078837
Hi,

Follow up:

<body onLoad="document.form1.reset();">

make sure to right click your form, click properties and in the form name field type form1 don't type FORM1 or Form1, just form1.

Regards
hhammash
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 
LVL 4

Expert Comment

by:CRagsdell
ID: 8081834
hhammash's fix will blank the form, but the user can still resubmit the form, which was another part of the "problem" posed by jamesjs.

My solution will prevent both the viewing of the entries and prevent the resubmission of the form.
0
 
LVL 14

Expert Comment

by:hhammash
ID: 8082175
Hi Jamesjs,

If the user click back button and finds it disable he can go back and access the form from the main link.

The simple solution to that is to put validation for the first field.  So when the user clicks the back button he/she will not be able to submit it blank.

Also you can put this Meta Tag under your <HTML> to refresh the form is the user leave it while fillign for any emergency.  I mean if the user had a reason to leave the form filled but unfinished on the screen,  it will refresh itself so that nobody can read it.

<META HTTP-EQUIV="Refresh" CONTENT="30;URL="http//www.yourweb.com/page.htm">

Best regards
hhammash


0
 
LVL 4

Expert Comment

by:CRagsdell
ID: 8082403
With my solution, the user can not resubmit the form once submitted unless he starts a new session. A refresh nor form field validation will prevent that. And if he hits the "main link" (as posed by hhammash) to go back to the form, once again he doesn't get the form if already submitted.

If you want the user to not be able to resubmit the form again, use a non-expiring cookie and check it instead of the session variable. If you want him to be able to resubmit the form SOMETIME in the future, expire the cookie after the appropriate time period.
0
 
LVL 14

Expert Comment

by:hhammash
ID: 8082483
Hi CRagsdell,

I am not saying that your solution is wrong.  Please don't feel that I am debating here, we are trying to reach to a solution here.

Question:
---------

How are you going to stop the user form going to the main link and prevent him/her from submitting the form again.

By IP: He/she can use another computer if not already behind a DHCP.

By user name and password:  Jamesjs can put the combination as a primary key in the database so no matter how many times they submit,  they will only access the database once.

I like your solution, and I admired the code that you put. You handled it perfectly. I just gave my easy solution to Jamesjs and he can select the one he feels suitable.

We are all friends here, so please don't feel or think that I am saying that your solution is not good.

In fact I liked it.

With my best regards CRagsdell
hhammash




0
 
LVL 4

Expert Comment

by:CRagsdell
ID: 8082974
hhammash,

I appreciated your answer as well, but it just didn't address the resubmission issue. I would have offered the same solution if he hadn't added that he didn't want them to be able to resubmit the form.

Using a session value (or cookie if you want to restrict past the current session) to determine if the form has been previously submitted and then decide whether to show the form or not will prevent the user from going to the main link and trying to resubmit the form- they never see the form.
0
 
LVL 14

Expert Comment

by:hhammash
ID: 8083024
Hi,

Thank you CRagsdell,

I did not address the resubmission issue.

What I understood is that jamesjs was worried about the user to press back button and find the form already filled and submits it again. This is why I did not address it.

Also he can make the record as Primary Key so the same user can enter once to the database,  no matter how many times he/she submits the form.

Good we cleared the issue no.

Thank you CRagsdell for the follow-up.

Best regards
hhammash
0
 
LVL 29

Expert Comment

by:coreybryant
ID: 8989111
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept CRagsdell's comment as answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

coreybryant
EE Cleanup Volunteer
0
 
LVL 4

Expert Comment

by:CRagsdell
ID: 8989276
coreybryant,

Thanks for the cleanup!

CR
0

Featured Post

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question