Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Referer Page

Posted on 2002-06-18
16
Medium Priority
?
309 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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:Michel Sakr
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 200 total points
ID: 7090971
0
 

Author Comment

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

Featured Post

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!

Question has a verified solution.

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

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…
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/…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

886 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