I have a landing page with a form in it. the form has a form action to a php file. I send all the fields that the client filled to a an api, like that:
$input_email = isset($_POST['email']) ? check_plain($_POST['email']) : 'None';
$input_name = isset($_POST['name']) ? check_plain($_POST['name']) : 'None';
$input_website = isset($_POST['website']) ? check_plain($_POST['website']) : 'None';
$input_website = strtolower($input_website);
$input_content = isset($_POST['content']) ? check_plain($_POST['content']) : 'None';
$previous = $_SERVER['HTTP_REFERER'];
As you can see in the last line, i get the HTTP_REFERER from the page. But doing this brings back the url of the landing page, and not the referral url for the landing page. (for example: if my landing page is example.com and the client got there from google.com i want $previous to have google.com, but instead i have example.com)
Is there any way to make it work? Also note that I am aware of the problems with using HTTP_REFERER
So what's happening here is that your initial page load has the (assumed) correct http referer, but once the user posts the form, the referer becomes your own domain
In the form on the landing page you could do something along these lines
<?php if (isset($_SERVER['HTTP_REFERER'])): ?>
<input type="hidden" name="http_referer" value="<?= $_SERVER['HTTP_REFERER']; ?>" />
<?php endif; ?>
Then when you do your post processing you can check for the existence of
$_POST['http_referer']
and act accordingly