I have a page called, displayContact.php. This page pulls up the details for a given user in the database. I have designed this page to accept a uID from several other pages, so there are many pages that can send me to displayContact.php. I'm trying to fix it so that when I click the "Update Database" button, it displays a text link that will allow me to return to the other page that brought me to displayContact.php in the first place. displayContact.php simply reloads itself when the "Update Database" button is clicked.

My problem is that the $sendBack URL is never the URL of the webpage that brought me to displayContact.php Does this make sense? Here is my code. I've attemped to write it so the referrer would not be over-written when displayContact.php reloads to update the database with changes made. This code appears in the section on my page where it checks for the action... if $action=viewRecord. If my understanding is correct, this code should only be executed once, that is, when the page is first loaded. But somehow $sendBack is being changed when the page reloads.

Please help.

Code:
$referrer = $_SERVER['HTTP_REFERER'];
if ($captured_referrer =="") {
$sendBack = $referrer;
$captured_referrer = "Yes";
}