note 99245 added to language.variables.external
| From: | stephen dot washburn at mac dot com | Date: | Thu, 05 Aug 2010 17:32:35 +0000 |
| Subject: | note 99245 added to language.variables.external | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171407@lists.php.net to get a copy of this message | ||
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']);
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 17.107.80.97
----
Manual Page -- http://www.php.net/manual/en/language.variables.external.php
Edit -- https://master.php.net/note/edit/99245
Del: integrated -- https://master.php.net/note/delete/99245/integrated
Del: useless -- https://master.php.net/note/delete/99245/useless
Del: bad code -- https://master.php.net/note/delete/99245/bad+code
Del: spam -- https://master.php.net/note/delete/99245/spam
Del: non-english -- https://master.php.net/note/delete/99245/non-english
Del: in docs -- https://master.php.net/note/delete/99245/in+docs
Del: other reasons-- https://master.php.net/note/delete/99245
Reject -- https://master.php.net/note/reject/99245
Search -- https://master.php.net/manage/user-notes.php