Okay so my page is a feedback form for a website. The user enters their feedback (name, comments, etc) into the form. There is a hidden field that is to store the http_referer. Once the user fills in the form, they 'preview' their feedback before they can send it. Problem is, when they preview it, the http_referer is changed to that of the form's original page instead of the site that they got to the form from.
The referer is stored in a Feedback object, and when the preview page is rendered, the form is rendered again underneath the preview, causing a 'new' Feedback object I believe.
Is there a way that I could have some sort of variable that I could use for the entire page (global variable or something?) that I could use to determine whether or not it is the first time the form is rendered (therefore storing and keeping only the first referer)? The main problem is trying to get around the new Feedback object being initialized.
The code:
index.php:
include('Controller.class.php'); ?>
$C = new Controller;
if(!array_key_exists('action', $_REQUEST)) {
$_REQUEST['action'] = 'form';
}
$cmd = '$C->' . $_REQUEST['action'] . '();';
eval($cmd);
Controller.class.php:
function form() {
$fb = new Feedback;
if (isset($_REQUEST['http_referer'])){
if ($_REQUEST['http_referer'] == '') {
$fb->http_referer = $_SERVER['HTTP_REFERER'];
} else {
$fb->http_referer = $_REQUEST['http_referer'];
}
}