[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 09-11-2005, 09:49 AM   #1 (permalink)
dre
NamePros Regular
 
Join Date: Jul 2005
Posts: 593
98.85 NP$ (Donate)

dre has a spectacular aura aboutdre has a spectacular aura about


getting Refferer with Javascript

hey, does anyone know how to get the refferer with javascript then pass it on to a php script for that to write to a text file? i got the php bit sorted i just need the java script bit to place in my .html to pass the vars to my php script

Code:
<!--
  stats = "referrer=" + escape(window.document.referrer);
  stats += "agent=" + escape(navigator.userAgent);
  document.write('button.php' + stats +'">');
//-->
dre is offline  
Old 09-11-2005, 10:10 AM   #2 (permalink)
NamePros Member
 
Join Date: Sep 2005
Posts: 71
136.00 NP$ (Donate)

lemmin is an unknown quantity at this point


how about the server variable $_SERVER('http_referer')

That's the server variable for asp. I don't do php, but I'm pretty sure it's the same.


By the way, I have never gotten that varible to return anything in asp, but if your Jscript is working, you can submit it to a php file through a form on load. Just use something like:

HTML Code:
<body onLoad="myForm.submit()">
<form id="myForm" action="refered.php" method="POST">
<input type=hidden value=referrer> 
I'm sure there's an easier way, but that's what popped into my head
lemmin is offline  
Old 09-11-2005, 10:11 AM   #3 (permalink)
NamePros Regular
 
Join Date: Aug 2005
Posts: 214
170.00 NP$ (Donate)

slantednet is on a distinguished road


If the end result is PHP, why not get the referrer in PHP?

<?php
$ref= $_SERVER['HTTP_REFERER'];
?>

However, don't rely on it too much, since the referer is sent from teh client, it's not trustworthy.
__________________
OnlineGames.net
slantednet is offline  
Old 09-11-2005, 10:17 AM   #4 (permalink)
dre
NamePros Regular
 
Join Date: Jul 2005
Posts: 593
98.85 NP$ (Donate)

dre has a spectacular aura aboutdre has a spectacular aura about


i dnt want to use straight php, because i of to put in .tpl files, so if i get the details then pass it to a remote php script that then writes to a txt file, that possible?
dre is offline  
Old 09-11-2005, 11:23 AM   #5 (permalink)
NamePros Regular
 
Join Date: Aug 2005
Posts: 214
170.00 NP$ (Donate)

slantednet is on a distinguished road


What's wrong with your existing code (with a few mods)?

Code:
<!--
  stats = "?referrer=" + escape(window.document.referrer);
  stats += "&agent=" + escape(navigator.userAgent);
  document.write('button.php' + stats);
//-->
That should output "button.php?referrer=<referrer here>&agent=<agent here>" into the page where you have the script... no?
__________________
OnlineGames.net
slantednet is offline  
Old 09-11-2005, 11:33 AM   #6 (permalink)
dre
NamePros Regular
 
Join Date: Jul 2005
Posts: 593
98.85 NP$ (Donate)

dre has a spectacular aura aboutdre has a spectacular aura about


that code i post doesnt work
dre is offline  
Old 09-11-2005, 02:20 PM   #7 (permalink)
NamePros Member
 
Join Date: Sep 2005
Posts: 71
136.00 NP$ (Donate)

lemmin is an unknown quantity at this point


Quote:
Originally Posted by dre
if i get the details then pass it to a remote php script that then writes to a txt file, that possible?
Did you see the code I posted? Because, that's what it does.
lemmin is offline  
Old 09-11-2005, 02:28 PM   #8 (permalink)
dre
NamePros Regular
 
Join Date: Jul 2005
Posts: 593
98.85 NP$ (Donate)

dre has a spectacular aura aboutdre has a spectacular aura about


im not using a FORM!
dre is offline  
Old 09-11-2005, 10:18 PM   #9 (permalink)
NamePros Member
 
Join Date: Sep 2005
Posts: 71
136.00 NP$ (Donate)

lemmin is an unknown quantity at this point


Why wouldn't you want to use a hidden form?
lemmin is offline  
Old 09-11-2005, 10:27 PM   #10 (permalink)
NamePros Regular
 
Join Date: Aug 2005
Posts: 214
170.00 NP$ (Donate)

slantednet is on a distinguished road


eh... tired of playing hide-and-seek with help-seekers, constantly guessing what the problem could be because of lack of working info, like errors, results, source, desired operation, desired output, what you've tried on your own, etc...

Diagnosing software and server issues is often difficult work without being able to see or understand the whole picture. It's funny how people want to give you just a tiny, half worn, and barely recognizable peice of a puzzle and ask for someone to describe the completed picture to them. Then, when someone takes time out of their day to attempt to help, the seeker dares to get short with the helper... eh, tough sh*t, figure it out yerself.. I originally wondered why few people dive in to help in various forums, especially the programming one, and now I see that they probably just gave up on ungrateful requestors...

For future reference, here's a decent guide on how to ask a question:

How to ask questions the smart way

Particularly important would be the following sections:

Discuss your problem's symptoms, not your guesses

Discuss your problem's symtoms, in chronological order

Describe the goal, not the step

and

Courtesy never hurts, and sometimes helps

Good luck finding a solution,
Mike
__________________
OnlineGames.net

Last edited by slantednet; 09-11-2005 at 10:33 PM.
slantednet is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript / PHP Question Zubair1 Programming 4 08-20-2005 08:55 AM
looking someone that knows javascript REALLY well.... axilant Programming 3 04-29-2005 02:24 AM
Loading different images depending on the browser (JavaScript) Nevsan Programming 3 04-04-2004 09:36 AM
How do you detect resolution & launch an app with javascript? Rhino1616 Programming 14 12-04-2003 04:10 PM
Javascript Functions: Your needs. Mp)Tarh Web Design Discussion 1 11-15-2003 05:50 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 02:15 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85