Solved

Referer Page

Posted on 2002-06-18
16
276 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Choose the older file FSO 6 47
Generate report pulling data (links) from three tables 31 64
is this a cms? 8 58
ASP/VB email question 4 30
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 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

10 Experts available now in Live!

Get 1:1 Help Now