interesting problem...

6

6

I have an asp page with a form that collects name, email address, etc. the
form page posts to itself so what I do is check to see if the request method
is POST and if it is I grab the data, do something with it, and display a
message below the form. I want to implement an image verification (captcha)
system. the problem I have is that when you submit the form if the captcha
test fails, all the info you entered into the form is cleared and the user
has to start over. I want the info to stay until the form is successfully
submitted. now, I can set the default value of the text fields to
request.form("fieldname"), but the problem here is that I WANT the info to
be cleared when the form is submitted (users are used to this happening and
if the data stays in the form after a good submission they will be confused)

is there something clever I can do here?
 
A

Anthony Jones

6 said:
I have an asp page with a form that collects name, email address, etc. the
form page posts to itself so what I do is check to see if the request method
is POST and if it is I grab the data, do something with it, and display a
message below the form. I want to implement an image verification (captcha)
system. the problem I have is that when you submit the form if the captcha
test fails, all the info you entered into the form is cleared and the user
has to start over. I want the info to stay until the form is successfully
submitted. now, I can set the default value of the text fields to
request.form("fieldname"), but the problem here is that I WANT the info to
be cleared when the form is submitted (users are used to this happening and
if the data stays in the form after a good submission they will be confused)

is there something clever I can do here?

Function GetDefault(Name)
If mbFailed Then
GetDefault = Server.HTMLEncode(Request.Form(Name))
End If
End Function

<input value="<%=GetDefault("field1")%> name="field1" />

I would recommend that you make yourself familar with the VBScript language
such constructs as If Else End If and Function are really useful sometimes.
 
S

SLH

Anthony Jones said:
Function GetDefault(Name)
If mbFailed Then
GetDefault = Server.HTMLEncode(Request.Form(Name))
End If
End Function

<input value="<%=GetDefault("field1")%> name="field1" />

I would recommend that you make yourself familar with the VBScript
language
such constructs as If Else End If and Function are really useful
sometimes.
close but doesnt work. it keeps the data even when the verification is
successful. you should try it out and youll see.
anyone else have any ideas?
 
A

Anthony Jones

SLH said:
close but doesnt work. it keeps the data even when the verification is
successful. you should try it out and youll see.
anyone else have any ideas?

Yep it were broken here's one that works:-

<%

Dim mbFailed : mbFailed = True

If Request.ServerVariables("HTTP_METHOD") = "POST" Then
mbFailed = LCase(Request.Form("field1")) <> "bad"
End If

%>
<html>
<body>
<form method="POST" action="test.asp">
<input name="field1" value="<%=GetDefault("field1")%>" />
<input type="submit" value="Post" />
</body>
</html>
<%
Function GetDefault(Name)
If Not mbFailed Then
GetDefault = Server.HTMLEncode(Request.Form(Name))
End If
End Function
%>
 
S

SLH

dude... all due respect, that doesnt even DO anything.
thanks for your help but if youre not going to provide a complete working
example id rather give up now
 
M

Mike Brind

6 said:
I have an asp page with a form that collects name, email address, etc. the
form page posts to itself so what I do is check to see if the request
method is POST and if it is I grab the data, do something with it, and
display a message below the form. I want to implement an image verification
(captcha) system. the problem I have is that when you submit the form if
the captcha test fails, all the info you entered into the form is cleared
and the user has to start over. I want the info to stay until the form is
successfully submitted. now, I can set the default value of the text fields
to request.form("fieldname"), but the problem here is that I WANT the info
to be cleared when the form is submitted (users are used to this happening
and if the data stays in the form after a good submission they will be
confused)

is there something clever I can do here?

This is *really* clever. Don't show the form after a successful submission.
It confuses users.
 
J

Jim D

would be even more clever to read closely. i never said "dont show the
form", clearly what i said was that the data the user just typed should be
cleared, which is the default behavior on every form on the web.

so, any *clever* ideas?
 
M

Mike Brind

I read your post closely enough to wonder why on earth you would want to
present a blank form to users *after* a successful submission. This is
*not* the behaviour that most users would expect, which is why you never see
any professional site do it. The only time I present a blank form after
successful submission is if I expect further submissions from the same user.
If you wanted to allow users to make multiple submissions, you would not
want to clear their name, address etc. You would retain it, so this is
obviously not what you are doing. I suggest you do something new for you -
take your head out of your arse and think about it for just one nanosecond.

But if you are insistent on showing blank forms, go ahead. Go with
Anthony's suggestion to try and understand If... Then... Else. What you
want to do is very simply solved with a basic understanding of the
construct.

In your first post as "Jimmy" you said you have a "client", which suggests
you are getting paid to create whatever app it is you are posting about. So
far as I can see, you have contributed nothing to it, but relied on people
here to do it all for you. Now you have insulted and abused so many of us
that no one is prepared to help you any more, so you keep changing your
identity.

Well, Jimmy/Joe Reynolds/SLH/6/Jim D - you are on your own as far as I am
concerned.

Good bye.

Jim D said:
would be even more clever to read closely. i never said "dont show the
form", clearly what i said was that the data the user just typed should be
cleared, which is the default behavior on every form on the web.

so, any *clever* ideas?
 
B

Bob Lehmann

if youre not going to provide a complete working example id rather give
up now

What a ridiculous comment!

I'd suggest that you just give up. You obviously have no aptitude or desire
for this, dude.

Bob Lehmann
 
A

Anthony Jones

SLH said:
dude... all due respect, that doesnt even DO anything.
thanks for your help but if youre not going to provide a complete working
example id rather give up now

Works fine. Does what you asked. If the input doesn't validate (in this
case typing the word 'bad') the form comes back with the data still intact
else it comes back blank.
 
J

Jim D

if youre lonely and pathetic enough to care, we work in teams of 2
developers, and share a dev station. rarely does anyone care enoguh to
change the name on the OE profile used for posting, hence the several names.

and one other thing... "arse"?


Mike Brind said:
I read your post closely enough to wonder why on earth you would want to
present a blank form to users *after* a successful submission. This is
*not* the behaviour that most users would expect, which is why you never
see any professional site do it. The only time I present a blank form
after successful submission is if I expect further submissions from the
same user. If you wanted to allow users to make multiple submissions, you
would not want to clear their name, address etc. You would retain it, so
this is obviously not what you are doing. I suggest you do something new
for you - take your head out of your arse and think about it for just one
nanosecond.

But if you are insistent on showing blank forms, go ahead. Go with
Anthony's suggestion to try and understand If... Then... Else. What you
want to do is very simply solved with a basic understanding of the
construct.

In your first post as "Jimmy" you said you have a "client", which suggests
you are getting paid to create whatever app it is you are posting about.
So far as I can see, you have contributed nothing to it, but relied on
people here to do it all for you. Now you have insulted and abused so
many of us that no one is prepared to help you any more, so you keep
changing your identity.

Well, Jimmy/Joe Reynolds/SLH/6/Jim D - you are on your own as far as I am
concerned.

Good bye.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,139
Messages
2,570,805
Members
47,351
Latest member
LolaD32479

Latest Threads

Top