Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - get site referers in asp ???
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

get site referers in asp ???

 Post Reply Post Reply
Author
miladanimator View Drop Down
Groupie
Groupie
Avatar

Joined: 24 July 2005
Location: United States
Status: Offline
Points: 156
Post Options Post Options   Thanks (0) Thanks(0)   Quote miladanimator Quote  Post ReplyReply Direct Link To This Post Topic: get site referers in asp ???
    Posted: 20 December 2007 at 9:55pm
hi all ...

I use    request.ServerVariables("HTTP_REFERER")     to get my sitereferer adress ....

but this show the full adress of refferer like this : http://www.site.com/forum/post.aspx?pid=444&Page=5


but I need to get only the domain name of the referer ...

for example when the referer adress is : http://www.site.com/forum/post.aspx?pid=444&Page=5 ,  I need to get "Site.com"

anyone can help ???Cry
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post Posted: 21 December 2007 at 4:41pm
<%

    strURL = "http://www.site.com/forum/post.aspx?pid=444&Page=5"

    strURL = Replace(strURL,"http://","")
    strURL = Replace(strURL,"https://","")
    strURL = Replace(strURL,"www.","")
    strURL = Left(strURL,InStr(1, strURL, "/", 1))

    Response.Write(strURL)

%>


I havent tried it but that should work.
S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
miladanimator View Drop Down
Groupie
Groupie
Avatar

Joined: 24 July 2005
Location: United States
Status: Offline
Points: 156
Post Options Post Options   Thanks (0) Thanks(0)   Quote miladanimator Quote  Post ReplyReply Direct Link To This Post Posted: 22 December 2007 at 10:34pm
thanks a lot
it work correctly ...

now I write a code for webwizforum thet :
add site referers to database if the referer doesn't exist in database, and if the referer exist in database the input numper update ( refs = refs + 1) ...
I write this code ...
but I get one error :(  any one can help ????

<%
    dim strURL
    dim blnnewref
    strURL = Request.ServerVariables("HTTP_REFERER")
    strURL = Replace(strURL,"http://","")
    strURL = Replace(strURL,"https://","")
    strURL = Replace(strURL,"www.","")
    strURL = Left(strURL,InStr(1, strURL, "/", 1))
    if strURL <> "" then
    Response.Write(strURL)


'Check the database
strSQL = "SELECT " & strDbTable & "Refs.Url " & _
"FROM " & strDbTable & "Refs" & strDBNoLock & "  " & _
"WHERE " & strDbTable & "Refs.Url = '" & strURL & "';"
rsCommon.Open strSQL, adoCon
If NOT rsCommon.EOF Then blnnewref = true
rsCommon.Close

' Add Site Referer to database
If blnnewref = false then
strSQL = "SELECT tblrefs.url, tblrefs.title FROM tblrefs ;"
With rsCommon
.CursorType = 2
.LockType = 3
.Open strSQL, adoCon
.AddNew
.Fields("url") = strURL
.Fields("title") = strURL
.Update
.Close
End With

else

dim refs
dim refid
strSql = "Select tblrefs.* From  tblrefs Where url =" & strURL
rscommon.Open strSQL, adoCon
refs = rscommon("refs")
refid = rscommon("ref_id")
adocon.Execute "UPDATE tblrefs SET refs = refs + 1 WHERE id =" & refid       
rscommon.close
 
End if
End if 
%>
Back to Top
miladanimator View Drop Down
Groupie
Groupie
Avatar

Joined: 24 July 2005
Location: United States
Status: Offline
Points: 156
Post Options Post Options   Thanks (0) Thanks(0)   Quote miladanimator Quote  Post ReplyReply Direct Link To This Post Posted: 22 December 2007 at 10:41pm
in my code, when a referer doesn't exist in database, it successfully add to database ...

but when a referer exist in database, this error was occured :

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression 'url =localhost/'.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.