|
 |
asp_databases thread: Refreshing page adds new record - help!
Message #1 by "Matthew Parlane" <matthew.parlane@t...> on Sun, 14 Jan 2001 08:32:22 -0000
|
|
Hi guys...
I have a page which calls itself from a form, and I have a line near the
top which says
<%
if request.form("add") = "Add to Database" then
...
and from there it goes on to add the record from the form to the database
- my problem is that when I refresh the page, request.form("add") still
equals "Add to Database", so it goes and adds the record again. I am stuck
and need help...
Let me know if you need me to post more code...
cheers,
Big Matty
Message #2 by Ashish Thakur <athakur@q...> on Sun, 14 Jan 2001 17:49:49 +0530
|
|
try :
if (lcase(cstr(request.form("add"))) = "add to database") then
watch out for the lower case string comparison - you may want to do it with
a UCase and "ADD TO DATABASE" also (ur choice)
if that does not work try passing an integer value (1 for add, 0 for do not
add) for the form field "add", that should remove all ambiguity
regs,
ashish thakur
sr. software engineer
QUARK Inc.
///////////////////////////////////
-----Original Message-----
From: Matthew Parlane [mailto:matthew.parlane@t...]
Sent: Sunday, January 14, 2001 2:02 PM
To: ASP Databases
Subject: [asp_databases] Refreshing page adds new record - help!
Hi guys...
I have a page which calls itself from a form, and I have a line near the
top which says
<%
if request.form("add") = "Add to Database" then
...
and from there it goes on to add the record from the form to the database
- my problem is that when I refresh the page, request.form("add") still
equals "Add to Database", so it goes and adds the record again. I am stuck
and need help...
Let me know if you need me to post more code...
cheers,
Big Matty
Message #3 by "Dallas Martin" <dmartin@z...> on Sun, 14 Jan 2001 09:38:25 -0500
|
|
It will add itself to the database forever. You have to insert code, either
in the ASP page or the SPROC
to check for a previous entry. There is one trick that you could do.
<%
dim counter, message
counter = request.form("counter")
if request.form("add") = "add" then
counter = request.form("counter")
if counter <> "" then
message = "This page has been previously submitted<br>"
else
counter = "SUBMITTED"
end if
end if
%>
<html>
<body>
<form action="sample.asp" method=POST>
<%=message%>
<input type=hidden name="counter" value="<%=counter%>">
The value of counter is: <%=counter%>
<br>
<input type=submit name="add" value="add">
</form>
</body>
</html>
----- Original Message -----
From: "Matthew Parlane" <matthew.parlane@t...>
To: "ASP Databases" <asp_databases@p...>
Sent: Sunday, January 14, 2001 3:32 AM
Subject: [asp_databases] Refreshing page adds new record - help!
> Hi guys...
>
> I have a page which calls itself from a form, and I have a line near the
> top which says
> <%
> if request.form("add") = "Add to Database" then
> ...
>
> and from there it goes on to add the record from the form to the database
> - my problem is that when I refresh the page, request.form("add") still
> equals "Add to Database", so it goes and adds the record again. I am stuck
> and need help...
>
> Let me know if you need me to post more code...
>
> cheers,
>
> Big Matty
>
Message #4 by Peter Zahos <pzahos@s...> on Sun, 14 Jan 2001 20:50:40 +0800
|
|
Try putting the code that adds a new record on a seperate asp page, not the
same page and if the add record is succesful, have it redirect back to the
main page. Then it can never be refreshed.
It will be interesting to see how others would handle you query!!
Good luck.
-----Original Message-----
From: Matthew Parlane [mailto:matthew.parlane@t...]
Sent: Sunday, 14 January 2001 4:32 PM
To: ASP Databases
Subject: [asp_databases] Refreshing page adds new record - help!
Hi guys...
I have a page which calls itself from a form, and I have a line near the
top which says
<%
if request.form("add") = "Add to Database" then
...
and from there it goes on to add the record from the form to the database
- my problem is that when I refresh the page, request.form("add") still
equals "Add to Database", so it goes and adds the record again. I am stuck
and need help...
Let me know if you need me to post more code...
cheers,
Big Matty
|
|
 |