How To Save First REFERER Url With Jquery And Then Post It In A Form Text Field

gulp86

New member
Sep 6, 2009
94
2
0
Ive tried multiple solutions but when i actually tried it, they dont work. Im looking for a way to save the referer URL so when the user keeps browsing the site until it lands on a contact page and submits ill get the referer.

There i would like to post the url referer in a hidden text form field as part of the contact form.


This needs to be done using just jquery becuase i want to be able to use it in non-php pages. Ive tried a jquery cookie plugin, but it didnt work for me.
Anyways, if somebody knows a working code to get this done and then post it in a text field i would really appreciate it.

In short: i need to store the http referer url in a session or cookie, then post it inside a form field that resides in a particular contact page and i need to do it using jquery.


Can somebody take a look at this possible solution and maybe post the exact code you are using to make it work?

possible solution: Using Referrer URLs to Better Understand Your Visitors


DISCLAIMER: ive tried that solution and i couldnt make it work.


Please help
 


you could easily accomplish this by creating a dynamic js file. code it like a normal php page and output javascript headers and js code in it, and echoing out the referrer in the js code where you need it. and call the php script as a external js file as normal. You could even take it a step further and use htaccess to rename the .php to .js if you like.

but most important your php needs to have this in it first

Code:
<?php 
header('Content-Type: application/javascript');
?>

using this php as a external js script will allow you to include php functionality into normal html pages.