View Full Version : Reseting $_GET values

04-13-2004, 07:12 PM
Is there a way to reset the $_GET values so that when a user hits "refresh", or "back" in their browser the code is not executed again?


$oData = new objData();
if($_GET['dir']!=="") {
$dir = $_SESSION['dir']; //Get stored directory path

if($_GET['dirAction'] == "add") { //Add the directory to the current dir string
$dir .= "/" . $_GET['dir'];

} elseif ($_GET['dirAction'] == "delete") { //Delete the directory from the current dir string
$arrDir = explode("/",$_GET['dir']);
$arrPath = array_slice($arrDir,0,count($arrDir)-1);
if(count($arrPath)>0) $dir = implode('/', $arrPath);

$_SESSION['dir'] = $dir;

A typical url string would read:

The only problem is that when the user hits refresh the code above looks to set the directory as root/folderFoo/folderFoo (instead of just root/folderFoo) and produces an error because that folder does not exist.

Thanks for any help!

04-13-2004, 08:33 PM
Hmm. I think you eiher need to redirect (--> header('Locarion etc') ) but this has all sort of other issues like users jumping back etc. I find that the most secure way is to set a flag in a sessionvariable.

session_start(); // at the top of your page
if (isset($_SESSION['processed']) and ($_SESSION['processed']=='yes')){
//print a message or redirect
} else {
... // other code and processing

Before you proces your request, you then check the sessionvariable.
On some strategical pages (homepag etc, you unset these sessionvariables)