Insert to db when clicking a link.

This is a discussion on "Insert to db when clicking a link." within the Classic ASP section. This forum, and the thread "Insert to db when clicking a link. are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 8th, 2004, 08:56
New Member
Join Date: Jun 2004
Location: United Kingdom
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Insert to db when clicking a link.

Hi, first post so be gentle!

I am doing a site for a friend that is basically a linking site.

What he wants is for registered individuals to be able to click through image links, when signed in, but be able to track which links they visited.

I, so far, have the login via the home page creating a session called username (original I know!) and was looking at turning each image link into an image submit button. Clicking the image causes an insert statement to run putting the session name into the database.

My question (at last) is; on a response.redirect is it possible to declare the target="_blank" as well? if not any other way to open the link in a new window and do the insert?

  #2 (permalink)  
Old Jun 8th, 2004, 10:35
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
Nope, thats not possible. One option is not to use Resonse.Redirect, but instead Response.Write some javascript which opens a new window which contains a page which does the insert.
  #3 (permalink)  
Old Jun 8th, 2004, 14:39
New Member
Join Date: Jun 2004
Location: United Kingdom
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
hmm didn't think it would be. Thanks.

Now I have the problem of convincing Dreamweaver that that is the case. It writes it's own strange code for an insert that looks like this:

Code: Select all
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "link") Then

  MM_editConnection = MM_database_sql_STRING
  MM_editTable = "tralesh.bpc_links"
  MM_editRedirectUrl = "property.asp"
  MM_fieldsStr  = "email|value|link_clicked|value|date|value"
  MM_columnsStr = "email|',none,''|link_clicked|',none,''|date|',none,NULL"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
  
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

End If
So I am guessing something needs to be altered in there to turn that redirect url variable into the Javascript function, which I have no clue as yet on how to do it.
  #4 (permalink)  
Old Jun 8th, 2004, 14:55
Up'n'Coming Member
Join Date: Feb 2004
Location: Woodbridge, UK
Age: 27
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Trebz Send a message via MSN to Trebz
lol, don't use DW to write ASP and expect to then modify it yourself, doesn't work that way i'm afraid.

I'd write the ASP yourself.

All you want it the for the link to pass something back to the page, either in the session or maybe the querystring so an image link might go to /page.asp?img=1&clicked=true

Code: Select all
If img <> "" and CBool(clicked) = true then
  Call insert function
  display javascript popup to pop img1
  redirect back to /page.asp
else
  display page.asp
end if
  #5 (permalink)  
Old Jun 8th, 2004, 14:58
Up'n'Coming Member
Join Date: Feb 2004
Location: Woodbridge, UK
Age: 27
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Trebz Send a message via MSN to Trebz
Or even better, have a page called redirect.asp which all these images link to and pass a url variable.

Like redirect.asp?url=http://www.google.com

then log the link and session("username") when it's clicked.

Then for your image links just link them to the redirect and have your target="_blank"
Closed Thread

Tags
insert, clicking, link

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a div become visible on clicking a link? snappy Web Page Design 12 Jun 11th, 2008 19:25
Changing a session variable when clicking a link? Crow555 Classic ASP 0 May 15th, 2008 12:22
How do I insert link in to text Karenm Starting Out 2 Jun 12th, 2007 17:00
leave link underlined after clicking monfu Web Page Design 9 May 29th, 2006 17:47
HELP, ASAP- Lag time when clicking on link... how can I fix?? Snapa02 Web Page Design 6 Apr 26th, 2006 00:18


All times are GMT. The time now is 21:05.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43