i have a form (contactus plugin) where i want the url from the last visted page someone came from to be added in a hidden field
now someone suggested me to track the sessions on each page with
PHP
1
$_SESSION
[
'visited_pages'
][] =
$_SERVER
[
'HTTP_HOST'
].
$_SERVER
[
'REQUEST_URI'
].
$_SERVER
[
'QUERY_STRING'
];
and then get the last page with
PHP
1
$prev_page
=
$_SESSION
[
'visited_pages'
][(
count
(
$_SESSION
[
'visited_pages'
]-1)];
due to my lack of knowledge of php i dont know how to use it in the form.....
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if
(
$cfg
[
'plugin'
][
'contactus'
][
'subjects'
] !=
''
){
$cfgsubjects
=
explode
(
";"
,
$cfg
[
'plugin'
][
'contactus'
][
'subjects'
]);
if
(
count
(
$cfgsubjects
) > 1 && !
empty
(
$cfgsubjects
[1])){
$cfgsubj
=
"<select name=\"subject\">\n"
;
$iii
=0;
foreach
(
$cfgsubjects
as
$x
) {
if
(!
empty
(
$x
)) {
$subjects
[
$iii
] = trim(
$x
);
if
(
$iii
==
$subject
|| (
empty
(
$subject
) &&
$iii
==0)) {
$cfgsubj
.=
"<option value=\""
.
$iii
.
"\" selected=\"selected\">"
.
$subjects
[
$iii
].
"</option>\n"
;
}
else
{
$cfgsubj
.=
"<option value=\""
.
$iii
.
"\">"
.
$subjects
[
$iii
].
"</option>\n"
;
}
$iii
++;
}
}
$cfgsubj
.=
"</select>\n"
;
}
else
{
$cfgsubj
=
''
;
}
}
else
{
$cfgsubj
=
"<input type=\"hidden\" maxlength=\"100\" size=\"24\" value=\"URL HERE\" name=\"subject\" id=\"subject\" class=\"text\" />"
;
}
or if someone has a better solution to do this?