|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-04-12 09:51 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 10 10:00:01 2025 UTC |
Description: ------------ post variables appear in session after 3 posts... $_GET Array ( ) $_POST Array ( [search_didi] => asd [submitare] => Cautare simpla // !!!!!!!!! [submit] => Cautare // !!!!!!!!! ) $_SESSION Array ( [submitare] => Cautare simpla // !!!!!!!!! [submit] => Cautare // !!!!!!!!! [search_didi] => asd ) Reproduce code: --------------- Source code tested on php5.0.4, php5.1.2 (works fine on php4.4.0) <? session_start(); if(isset($_POST['submitare']) && ($_POST['submitare']=='Cautare simpla' || $_POST['submitare']=='Cautare avansata')){ foreach($_SESSION as $key=>$value){ if(preg_match("@_didi$@i",$key)){ unset($_SESSION["{$key}"]); } } foreach($_POST as $key=>$value){ //echo $key." ".$value."<hr>"; if(preg_match("@_didi$@i",$key)){ echo $key."=".$value."<hr>"; $_SESSION["{$key}"]=$value; } } } echo "<pre>"; print_r($_GET); print_r($_POST); print_r($_SESSION); echo "</pre>"; if(!isset($_POST['submitare']) && !isset($_GET['page'])){ foreach($_SESSION as $key=>$value){ if(preg_match("@_didi$@i",$key)){ unset($_SESSION["{$key}"]); } } } ?> <form action="" method="POST"> Cauta: <input type="text" name="search_didi" value="" /> <input type="hidden" name="submitare" value="Cautare simpla" /> <input type="submit" name="submit" value="Cautare" /> </form> Expected result: ---------------- $_GET Array ( ) $_POST Array ( [search_didi] => asd [submitare] => Cautare simpla // !!!!!!!!! [submit] => Cautare // !!!!!!!!! ) $_SESSION Array ( [search_didi] => asd )