Solved

Referer Page

Posted on 2002-06-18
16
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

734 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