Trying to clear variables because "REFRESH" adds a

Results 1 to 2 of 2

Thread: Trying to clear variables because "REFRESH" adds a

  1. #1
    David Highlander Guest

    Default Trying to clear variables because "REFRESH" adds a

    I am trying to clear the variables of a form after they have been added to the database. <BR><BR>Here is the scenario so you can understand why:<BR><BR>1. A user clicks MY LINKS on index.asp and can add a link. <BR>2. When they add a link the form takes them back to index.asp where I have an include file that holds this script:<BR><BR>&#060;% If Request.Form("linkname") &#060;&#062; "" Then %&#062;<BR>&#060;%<BR>linkname = TRIM( Request.Form("linkname") )<BR>linkaddress = TRIM( Request.Form("linkaddress") )<BR><BR>linkname = Replace(linkname, "&#039", "&#039&#039")<BR>linkaddress = Replace(linkaddress, "&#039", "&#039&#039")<BR><BR><BR>Dim Sqldetailslink, connlink<BR><BR>Set connlink = Server.CreateObject("ADODB.Connection")<BR>connlin ("intranet")<BR>Sqldetailslink = "INSERT INTO links (linkname, linkaddress, username)"_<BR> & "values (" _<BR> & "&#039" & linkname & "&#039, " _ <BR> & "&#039" & linkaddress & "&#039, " _ <BR> & "&#039" & Session("username") & "&#039)" <BR>connlink.Execute Sqldetailslink<BR>ELSE<BR>END IF<BR>connlink.close<BR>%&#062;<BR><BR>The problem is if they happen to Refresh the page index.asp the same link they just added is added one again. How can I clear these variables so that if a user happens to hit refresh the link is not added?<BR>

  2. #2 Guest

    Default RE: Trying to clear variables because

    I suggest that you submit your form to the page that accepts the form input data and inserts it into database. That page does the insert and redirects to another page, which could be your form input page. This will be the page where the client ends up. If he tries to refresh that page will be redisplayed, without trying to reinsert the data.<BR><BR>Also if you don&#039t want duplicates, you should query the db to see if the linkname and linkaddress already exist. If the returned recordset is not empty, then they already exist, so don&#039t add them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts