get site referers in asp ???
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=25045
Printed Date: 28 March 2026 at 7:40am Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: get site referers in asp ???
Posted By: miladanimator
Subject: get site referers in asp ???
Date 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 ???
|
Replies:
Posted By: Scotty32
Date 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 - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins
For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .
|
Posted By: miladanimator
Date 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 %>
|
Posted By: miladanimator
Date 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/'.
|
|