Hey all,
Hope this finds everyone well. I'm trying to use a little VB to get some user info from an off-line user manual that I write for my company's software. I've gotten something from Nathan Schmoll at aspalliance.com. He provides a nice little .asp patch to pass all my links through. FE: if I want a link to a page called MRFastCine.html, I pass it through this asp page guide.asp. The link is: guide.asp?/MRFastCine.html. The code is below:
<%
tg=request.querystring
if tg="" then
%>You must enter a target URL.<%
else
set myconn=server.createobject("ADODB.Connection")
myconn.open _
"Driver={Microsoft Access Driver (*.mdb)}; _
DBQ="&server.mappath("track.mdb")&";"
sql_query="SELECT * FROM trackdb"
set rs=myconn.execute(sql_query)
WHILE NOT RS.EOF
dburl=rs("url")
if dburl=tg then
matchup="1"
end if
rs.movenext
wend
if matchup="1" then
sql_query="SELECT * FROM trackdb WHERE url='"&tg&"'"
set rs=myconn.execute(sql_query)
oldcountnumber=rs("count")
sql_query="UPDATE trackdb SET _
count='"&(cint(oldcountnumber)+1)&"' _
WHERE url='"&tg&"'"
myconn.execute(sql_query)
else
sql_query="INSERT INTO trackdb (url, count) _
values ('"&tg&"', '1')"
myconn.execute(sql_query)
myconn.close
end if
response.redirect(tg)
end if
%>
Unfortunately, while this is nice, I need more information, so I've been trying to add to the information inserted. I've created a different table to handle ip, browser, referer, date and time. But the damn thing won't work. It keeps telling me that the values for ip, browser, referer, date and time are zero. Does anyone see anything wrong below? Please advise. Many thanks in advance. Omochango
<%
tg=request.querystring
if tg = " " then
ip = Request.ServerVariables("REMOTE_ADDR")
referer = Request.ServerVariables("HTTP_REFERER")
browser = Request.ServerVariables("HTTP_USER_AGENT")
date = date()
time = time()
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
You must enter a target URL.<%
else
set myconn=server.createobject("ADODB.Connection")
myconn.open "Driver={Microsoft Access Driver (*.mdb)}; DBQ="&server.mappath("guide.mdb")&";"
sql_query="INSERT INTO users (ip, referer, browser) values ('"&ip&"', '"&referer&"', '"&browser&"', '&date&','&time&')"
myconn.execute(sql_query)
sql_query="SELECT * FROM guide"
set rs=myconn.execute(sql_query)
WHILE NOT RS.EOF
dburl=rs("url")
if dburl=tg then
matchup="1"
end if
rs.movenext
wend
if matchup="1" then
sql_query="SELECT * FROM guide WHERE url='"&tg&"'"
set rs=myconn.execute(sql_query)
oldcountnumber=rs("count")
sql_query="UPDATE guide SET count='"&(cint(oldcountnumber)+1)&"' WHERE url='"&tg&"'"
myconn.execute(sql_query)
else
sql_query="INSERT INTO guide (url, count) values (' "&tg&" ', '1')"
myconn.execute(sql_query)
myconn.close
end if
response.redirect(tg)
end if
%>
******************************
Maferefun Chango baba mi ati gbobo Oricha!!!
Titi lae oba koso!! Titi lae obo oyo!! Kabiesile Kawo e!!!
**************************