Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 8th, 2005, 12:01 PM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default MySQL DB insert ASP problem

I have a asp page called 'reg_confirm.asp'

The problem i am having is that everytime the page is refreshed the MySQL DB is updated (i.e. my insert statement is run).

How can i only allow this once?

Code:

<% ' Last Edit: CRM_08mar05 %>

<%
agencyid = Session("agencyid")
forename = request.form("forename")
surname = request.form("surname")
comp_name = request.form("comp_name")
position = request.form("position")
email = request.form("email")

agency_id = request.form("agency_id")
agent_id = request.form("agent_id")
user_name = request.form("user_name")
pass_word = request.Form("pass_word")

response.write "agency_id = " & agency_id & "<br>"
response.write "agent_id = " & agent_id & "<br>"
response.write "user_name = " & user_name & "<br>"
response.write "pass_word = " & pass_word & "<br>"

'response.write "Agency ID = " & agencyid & "<br>"
'response.write "Forename = " & forename & "<br>"
'response.write "Surname = " & surname & "<br>"
'response.write "Comp Name = " & comp_name & "<br>"
'response.write "Position = " & position & "<br>"
'response.write "Email = " & email & "<br>"
function fixquotes(str)
        fixquotes=Replace(str,"'","")
end function

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Terms & Conditions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<%
set rsreg=con.execute("insert into authusers_reg (agencyid,forename,surname,company_name,email,posi tion) values ('"& agencyid &"','"& fixquotes(forename) &"', '"& fixquotes(surname) &"', '"& comp_name &"', '"& email &"', '"& fixquotes(position) &"')")
'response.write "" &("insert into authusers_reg (agencyid,forename,surname,company_name,email,posi tion) values ('"& agencyid &"','"& forename &"', '"& surname &"', '"& comp_name &"', '"& email &"', '"& position &"')")& "<br>"
%>
<body bgcolor="#f5f5f5">
<form name="form">
<table width="550" bgcolor="#ECECEC" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
    <td width="16" bgcolor="#ECECEC"><img src="images/top_lefbb.gif" width="16" height="16"></td>
    <td height="16" bgcolor="#ECECEC" background="images/top_midbb.gif"><img src="images/top_midbb.gif" width="16" height="16"></td>
    <td width="24" bgcolor="#ECECEC"><img src="images/top_rigbb.gif" width="24" height="16"></td>
</tr>
<tr>
    <td width="16" background="images/cen_lef.gif"><img src="images/cen_lef.gif" width="16" height="11"></td>
    <td><Table width="100%" border="1" bordercolor="#666666" align="center" cellpadding="0" cellspacing="1">
            <tr bgcolor="#006699" bordercolor="#000000" border="1"><Td width="100%" align="Left"><span class="style1"><strong>Registration Confirmation</strong></span></td>
         </tr>
         <%
         'forename = this.form.forename.value
         'response.write "Forename = " & forename & "<br>"
         %>
            <tr>
             <td height="25" align="center" bordercolor="#ececec" border="0">
             Congratulations <%=forename & " " & surname %>,
             </td>
            
         </tr>
            <tr><td height="25" align="center" bordercolor="#ececec" border="0">
            You have successfully registered
            </td>
         </tr>
         <tr bgcolor="#ececec" bordercolor="#ececec">
         <td bgcolor="#ececec" bordercolor="#ececec" align="center">
         <input type="button" name="finish" id="finish" value="Finish" onmouseover="style.cursor='hand'" onClick="location.href='logincheck.asp?agencyid=<% =agency_id%>&agentid=<%agent_id%>&username=<%=user _name%>&password=<%=pass_word%>'">
         </td></tr>
<%
'finish = this.form.finish.value
'response.write "Finish = " & finish & "<br>"

'if request.form("finish") = "finish" then
'response.redirect "/mackenzie/login.asp"
'end if
%>
    </table>
    </td>
    <td width="24" background="images/cen_rigBB.gif" bgcolor="#ECECEC"><img src="images/cen_rigBB.gif" width="24" height="11"></td>
</tr>
<tr bgcolor="#ECECEC">
    <td width="16" height="16"><img src="images/bot_lefbb.gif" width="16" height="16"></td>
    <td height="16" bgcolor="#ECECEC" background="images/bot_midbb.gif"><img src="images/bot_midbb.gif" width="16" height="16"></td>
    <td width="24" height="16" bgcolor="#ECECEC"><img src="images/bot_rigbb.gif" width="24" height="16"></td>
</tr>
</table>
</form>
</body>
</html>


www.crmpicco.co.uk
www.milklemonadechocolate.uk.tt
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
Reply With Quote
  #2 (permalink)  
Old March 8th, 2005, 01:05 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

One way you could get round it would be to redirect to another page where the congratulations message is shown as soon as you have run your insert query.

HTH,

Chris

Reply With Quote
  #3 (permalink)  
Old March 9th, 2005, 05:21 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

how would i do this?

www.crmpicco.co.uk
www.milklemonadechocolate.uk.tt
Reply With Quote
  #4 (permalink)  
Old March 9th, 2005, 05:27 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Make the changes to the db in the page your form submits to, then response.redirect to a page that displays the message. This way the if the client refreshes they just get the message page, but not the insert query etc.

Cheers,

Chris

Reply With Quote
  #5 (permalink)  
Old March 10th, 2005, 10:32 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

i just done a count on the db and if the count<>0 then do it else DONT!

www.crmpicco.co.uk
www.milklemonadechocolate.uk.tt
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to insert a date into MySQL from asp bleutiger Classic ASP Professional 8 May 5th, 2008 01:42 PM
ASP Insert , MS Access Db tigere Classic ASP Databases 0 November 11th, 2006 08:43 AM
ASP with MySQL db itHighway Classic ASP Basics 2 August 10th, 2005 12:28 AM
sort a asp mysql db crmpicco Classic ASP Databases 1 May 6th, 2005 11:59 AM
insert values into a MySQL DB from a drop down men crmpicco Classic ASP Basics 26 January 24th, 2005 08:10 AM



All times are GMT -4. The time now is 12:38 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.