| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Regular | 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 +'">');
//-->
__________________ Top of google EASY | $40 referrals :eek: Myspace Proxy FREE MP3's/AUDIO DOWNLOADS |
| |
| | #2 (permalink) |
| NamePros Member | 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> |
| |
| | #3 (permalink) |
| NamePros Regular | 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 |
| |
| | #4 (permalink) |
| NamePros Regular | 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?
__________________ Top of google EASY | $40 referrals :eek: Myspace Proxy FREE MP3's/AUDIO DOWNLOADS |
| |
| | #5 (permalink) |
| NamePros Regular | 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);
//-->
__________________ OnlineGames.net |
| |
| | #6 (permalink) |
| NamePros Regular | that code i post doesnt work
__________________ Top of google EASY | $40 referrals :eek: Myspace Proxy FREE MP3's/AUDIO DOWNLOADS |
| |
| | #8 (permalink) |
| NamePros Regular | im not using a FORM!
__________________ Top of google EASY | $40 referrals :eek: Myspace Proxy FREE MP3's/AUDIO DOWNLOADS |
| |
| | #10 (permalink) |
| NamePros Regular | 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. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
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 |