Solved

Referer Page

Posted on 2002-06-18
16
259 Views
Last Modified: 2008-02-01
If I put a link in this page when listing an item for sale:

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=1360970503

and my link will be like this:

http://mysite.com/url.asp?CODE=test

Can I do a script that will display two things:
1) The ebay item ID from the referer page
2) Code from the link I inserted into the page

I tried to do this but can't finish it:

--------------

<%
Dim URL ' As String

URL = Request.ServerVariables("HTTP_REFERRER")

response.write "<HTML><HEAD></HEAD><BODY>Your Ebay Item Number is: <br>"
response.write URL
response.write "</BODY></HTML>"


%>
0
Comment
Question by:amira123
  • 8
  • 7
16 Comments
 
LVL 2

Expert Comment

by:jsmckenzie
ID: 7090245
Not all servers send a referrer, so you can't guarantee that HTTP_REFERRER will always have a value.
0
 

Author Comment

by:amira123
ID: 7090282
Well, I am specifically trying to do this with Ebay.  Do you know if ebay does or does not?
0
 
LVL 2

Expert Comment

by:jsmckenzie
ID: 7090359
Sorry -- meant to say not all browsers send referrer info.
0
 
LVL 2

Expert Comment

by:jsmckenzie
ID: 7090391
plus ebay would have to put a link to your page in order to get the referrer information (doubtful, but you could always ask...).  If you are putting the link with the item number in the page, why would you need to get the number from somewhere else?  Perhaps I don't understand what you're trying to do.

You can display the info from your link by using this:

Response.Write Request.QueryString("CODE")
0
 

Author Comment

by:amira123
ID: 7090405
Ebay item numbers are addigned automatically by ebay once an item is inserted by me for an auction.

I can insert the link to my page by way of adding the link to the item description.

So we do need to do this this way:

1) Get the code number from my link that that is in the description area.

2) Get the ebay item number from the referere link

What would the code look like?
0
 
LVL 2

Expert Comment

by:jsmckenzie
ID: 7090463
sorry--haven't really used ebay.

so if you came from the ebay page your referrer would be http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=1360970503.  So to display the item number (assuming that the referrer information gets passed to your page, and assuming that the item number is the last thing on the URL) you could do something like this:

sReferrer = Request.ServerVariables("HTTP_REFERRER")
iItemPosition = InStr(sReferrer,"item=")
iItemNumber = Right(sReferrer,Len(sReferrer)-iItemPosition)
Response.Write "Your item number is " & iItemNumber

then to get the code from your link:

sCode = Request.QueryString("CODE")
Response.Write "The code is " & sCode


0
 
LVL 2

Expert Comment

by:jsmckenzie
ID: 7090469
you might have to make it:

iItemPosition = InStr(sReferrer,"item=") + 5
0
 

Author Comment

by:amira123
ID: 7090530
Ok it gives this error:

Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument: 'Right'

/scripts/ebay_refer/url.asp, line 4
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 20

Expert Comment

by:Silvers5
ID: 7090541
all major browsers send referer data.. and since 95% are using IE and 4% NS you'll get it..
0
 

Author Comment

by:amira123
ID: 7090612
ok so I got this to work:

<%

page = request.servervariables("HTTP_REFERER")
response.write "The page that refered you is<br>" & page & "<p>"

sCode = Request.QueryString("CODE")
Response.Write "The code is<br>" & sCode

%>

now i need to examine the value page and fine this pattern:
item=xxxxxx

and extract the xxxxx from it whatever number of characters is this xxxxx made up of.

How is that done?
0
 
LVL 2

Expert Comment

by:jsmckenzie
ID: 7090776
ok -- it should be:

iItemPosition = InStr(sReferrer,"item=") + 4

instead of

iItemPosition = InStr(sReferrer,"item=") + 5

That should get you the item number.


It's true that almost all browsers can return a refer value, but in some you can turn it off, and if you cut & paste a URL you won't get the correct refer info.  So you'll want to check for an empty referrer (and empty item number):

sReferrer = Request.ServerVariables("HTTP_REFERRER")

If Len(sReferrer) > 0 Then
   iItemPosition = InStr(sReferrer,"item=")
   If iItemPosition > 0 Then
      iItemNumber = Right(sReferrer,Len(sReferrer)-iItemPosition)
      Response.Write "Your item number is " & iItemNumber
   Else

      Response.Write "Can't get the item number."  

   End If

Else

  Response.Write "Can't get the HTTP_REFERRER"

End If
0
 

Author Comment

by:amira123
ID: 7090922
Well something is wrong with this code because it works the way I posted earlier.

Can you post your complete code so I can test it too?

Thanks
0
 

Author Comment

by:amira123
ID: 7090951
I am sorry, i meant to say that the code i posted earlier works but the one you posted dosent.  It says "Can't get the HTTP_REFERRER".  I don't understand what am I doing wrong?
0
 
LVL 2

Expert Comment

by:jsmckenzie
ID: 7090969
sReferrer = Request.ServerVariables("HTTP_REFERER")
sItemName = "item="

If Len(sReferrer) > 0 Then
  iItemPosition = InStr(sReferrer, sItemName) + (Len(sItemName) - 1)
  If iItemPosition > 0 Then
     iItemNumber = Right(sReferrer, Len(sReferrer)-iItemPosition)
     Response.Write "Your item number is " & iItemNumber
  Else

     Response.Write "Can't get the item number."  

  End If

Else

 Response.Write "Can't get the HTTP_REFERER"

End If
0
 
LVL 2

Accepted Solution

by:
jsmckenzie earned 50 total points
ID: 7090971
0
 

Author Comment

by:amira123
ID: 7091009
I thought I was losing my mind.  Thanks a bunch!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now