note 99245 deleted from language.variables.external by danbrown

From: Date: Thu, 05 Aug 2010 17:34:25 +0000
Subject: note 99245 deleted from language.variables.external by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-171408@lists.php.net to get a copy of this message
Note Submitter: stephen dot washburn at mac dot com ---- Many thanks to Wayne (http://www.php.net/manual/en/language.variables.external.php#82452) I have been struggling to figure out what to do with this, and this was PERFECT! I modified it slightly for my implementation so that I only worried about $_GET variables, but I REALLY appreciate it! Seriously, I was able to just drop this in and it worked immediately: if(!isset($_SESSION['skipnextget'])){ if($_GET) { //is there GET data? $newgetarr = array(); foreach($_GET as $key => $value) { if(is_array($value)) { $newvalue = implode(',',$value); //if it's an array, convert it to comma separated } else { $newvalue = $value; } $newgetarr[] = $key.'='.$newvalue; } $newget = implode('&',$newgetarr); $_SESSION['skipnextget'] = 1; } foreach($_POST as $key => $value) { $this[$key] = $value; } $_SESSION['postvars'] = serialize($this); //put POST in the session header("Location: http://" .$_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $newget); //reload page without POST data and shorter GET data exit(); }else{ unset($_SESSION['skipnextget']); } ?>

« previous php.notes (#171408) next »