Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write Info To Database When Link Is Clicked 1

Status
Not open for further replies.

dwg23

Technical User
Oct 21, 2002
151
US
Hello,
The company that I work for has a web site that registered users can log into and download files to update their machines with. What we would like to do now is record in the SQL database which users have downloaded which updates and when. All the user info is stored in session variables so all I would have to add is the date and off we go! The only problem is I have no idea on how to go about it. Any idea’s?
 
I'd make it a link to some code that inserts prior to redirecting them to the download.

So you could put

<a href="some_page.asp?x=filetobedownloaded">download it here</a>

on some_page.asp

SQL="insert into tblblah(fldUser,fldDocument,fldDate)Values('" & Session("svWhatever") & "','" & Request.querystring("x") & ".pdf" & "','" & date() & "';"
set rsTemp=rsConn.execute(SQL)
response.redirect(../folder/" & request.querystring("x") & ".pdf")

or roughly - in this example I appended the .pdf during the insert and redirection. You can get as fancy as you want - maybe right after do a javascript to call the document with a click here incase it does not download - link. and not redirect.

It's a general idea that you should be able to follow ok - heck if all documents are also stored in a database just bring some value along.

Stuart
 
Stuart,
Thanks, It looks easy enough to follow and I might just try putting the files in the database.

dwg23
 
Stuart,
Just a quick follow up.
I followed your example and it worked great!

Thanks again.
Dave
 
hey Dave

Thank you for letting us know.
Glad it worked good for you.

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top