...

View Full Version : Reseting $_GET values



Hawkmoon
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?

Example:


$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;
}
$oData->setDir($dir);

A typical url string would read:

directory.php?dir=folderFoo&dirAction=add
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!

raf
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.
Like


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
$_SESSION['processed']='yes';
}


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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum