asmith Posted December 11, 2007 Share Posted December 11, 2007 i've got a $_POST[john] which is an array (containing the values of a multiple select box) $_POST[john] = array("1" ,"2" , "3" ) $fruit = array ("1" => "apple" ,"2" => "orange" , "3" => "banana" ) for some reasons i had to do something like this , $a = array_rand($_POST[john]); $b = $_POST[john][$a]; echo $fruit[$b]; all the things run fine, no problem. when the user click on the submit button, $_POST[john] will be saved in a session. in the other page, there's a back button, which will redirect to this page. (IT WILL PUT THE SESSION VALUE INTO THE $_POST[john] AGAIN) here comes the problem , when i click on the back button, there is no echo from $fruit[$b] ! 2 times of the 3 ! sometimes it shows "apple" which means it has been 1 , but when it choses the 2 or 3 , it dosn't show orange and banana. what is this wierd problem ? why one value of the array works ? (i have echoed and print_r of all the $_POST[john], $fruit , $a , $b when i click the back button ,all shows the values, but i don't know why only this line : $fruit[$b] works 1 in 3 times !! ) Link to comment https://forums.phpfreaks.com/topic/81173-wierd-problem-with-array/ Share on other sites More sharing options...
Lumio Posted December 11, 2007 Share Posted December 11, 2007 Maybe it only shows you the cached page. Link to comment https://forums.phpfreaks.com/topic/81173-wierd-problem-with-array/#findComment-411881 Share on other sites More sharing options...
rajivgonsalves Posted December 11, 2007 Share Posted December 11, 2007 Yes, the back button of the browser will show you the cache page instead of the new one. Link to comment https://forums.phpfreaks.com/topic/81173-wierd-problem-with-array/#findComment-411884 Share on other sites More sharing options...
asmith Posted December 11, 2007 Author Share Posted December 11, 2007 nono , the back button is mine, <input type="submit" value="back" name="back"> if have , if isset($_POST[back]) then put all sessions variables to $_POST[...] , then load the fist page again , i said all the things run fine except this array. Link to comment https://forums.phpfreaks.com/topic/81173-wierd-problem-with-array/#findComment-411885 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.