Forum Moderators: coopster
I would like to repopulate the hidden source field based on which domain they came from.
I know the domains and which sources the would relate too.
This example is really close
[webmasterworld.com...]
Thanks
were you looking for a javascript or a php solution?
you can do as was mentioned there and test the referer, $_SERVER['HTTP_REFERER'] and then stick it into a $_SESSION.
The referer can be spoofed easily or may not be present at all but I store it and keep that in mind when interpreting data later.
THe form goes into a php based CRM, they allow javascript or php in the form.
What i forgot to mention in my first post, each domain = a different source value in the crm
Example.
example.com = Friend referral
example2.com = Adveritising
Does that make sense?
cheers
[edited by: jatar_k at 5:10 pm (utc) on Mar. 17, 2008]
does it use sessions already?
on each page you could include something like
if (!isset($_SESSION['myrefer'])) {
$_SESSION['myrefer'] = $_SERVER['HTTP_REFERER'];
}
you would need to use session_start(); at the top of all your scripts if the site doesn't use sessions already.
then you could just echo that session value into your form so it would be submitted with the form
take a look at the $_SERVER vars [php.net] there are a bunch of different ones, depending on how you want the data
It works, but not sure if it's the cleanest code.
<?php
$ref = $HTTP_SERVER_VARS["HTTP_REFERER"];
if (empty($ref)) {
$remote_host = "Direct Request";
}
else
{
$come_from = parse_url($ref);
$remote_host = str_replace("www.","",$come_from[host]);
switch ($remote_host)
{
case "ab.com":
$link = "ppc link";
break;
case "cd.com":
$link = "email link";
break;
case "de.com":
$link = "forum link";
break;
}
}
?>
and in my form
<input type="hidden" name="Questions[6794]" value="<?php echo $link; ?>" >