ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 21st, 2006, 02:13 AM
accessman2 accessman2 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 11 accessman2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 21 sec
Reputation Power: 0
Add 1 more record again when click refresh button

<%
dim varsubmit
varsubmit = request("varsubmit")
%>

<form method="post" name="addrecord">
<table>
<tr>
<td>Name:</td><td><INPUT TYPE="text" NAME="name" SIZE="20"></td><br>
</tr>

<tr>
<td>Score:</td><td><INPUT TYPE="text" NAME="score" SIZE="20"></td><br>
</tr>

<tr>
<td></td>
<td><input type="reset" value="Reset" />
<input type="submit" name="varsubmit" value="Submit" /></td>
</tr>

</table>
</form>

<%
if varsubmit="Submit" then
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"

conn.open "C:\Inetpub\db1.mdb"

sql="INSERT INTO Students (Name,Score)"


sql=sql & " VALUES "
sql=sql & "('" & request.form("name") & "'," & request.form("score") & ")"

on error resume next
conn.Execute sql,recaffected
if err=0 then
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
end if

I used above codes to add record when the user click the Submit button. I set Submit button value to be "Submit", if the value is "Submit", then add record.
But, when the user click the Refresh button at the menu bar, the web page will be refreshed and then add 1 more record again. If click refresh button again, then add 1 more record again.

How can I solve it?
I want to add record only clicking on Submit button.
I know that the action can solve this problem, eg. action="addrecord.asp", right.
But, I want to put it in the same file. Can we do it?

Please let me know, thanks.

Reply With Quote
  #2  
Old May 19th, 2006, 12:07 AM
rajkiran rajkiran is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 8 rajkiran User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 37 sec
Reputation Power: 0
Thumbs up Response.Redirect

HAHAHAHAAHAHA

its a classical problem

you see when you hit refresh the page it refreshes the pages last state i.e. one which was saved when you hit submit button on the page. so now every time will hit refresh it will reload that state of the page.

so whats the solution for the problem
simple

just response.redirect to same page after completing all you functionality.

this way page will be loaded as fresh copy .

thanks
www.lookforemails.com

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Add 1 more record again when click refresh button


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap