Referral capture form?
Mmm. Still doesn't seem to work Dave... I keep getting the latest referrer, not the original.
Viewing source seems to show the correct value (the oldest referrer) in the hidden field.
It may be your form tag:
<form method="POST" action="" class="form-horizontal" role="form"/>
Because it has an action of "" it will submit to the current url, which may be ?referrer=whatever and then when PHP runs it may combine the ?referrer from the URL and the hidden field and give priority to the one in the URL.
Can you try changing your form action to ? as in:
<form method="POST" action="?" class="form-horizontal" role="form"/>
Let me know if that works for you.
Sorry Dave - now I get no data captured in the "referrer" field... however the other standard fields "name, email, message" come through. I cleared my cookies initially to see if it was remembering that the first time I went there I went with out any referrer... but not win.
There might be something in the rest of your code that is interfering, try this updated script and see if it works exactly as intended on it's own and then try to integrate it.
I've renamed the variable returned and submitted to $oldestReferrer so it's clear what it is and it's distinct from the incoming referrer. And this update form shows what's being set, what's being submitted by the form, etc.
Let me know if the example form is working as intended.