IanG Posted April 3, 2007 Share Posted April 3, 2007 I was wondering how it would be possible to make $_POST variables persistent after a user refreshes the script. The problem I have on my page is that when the user hits submit to make a change to the page, it clears the $_POST variables from the previous submission which I need to use on the updated page. Quote Link to comment Share on other sites More sharing options...
grimmier Posted April 3, 2007 Share Posted April 3, 2007 Turn your POST variables into SESSION ones would work. Then just use the SESSION variables on the updated page. (they last longer) Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted April 3, 2007 Share Posted April 3, 2007 Store the previous post variables in sessions or hidden forms...then they will stay there to the update page. Quote Link to comment Share on other sites More sharing options...
IanG Posted April 3, 2007 Author Share Posted April 3, 2007 Thanks guys. I got it to work by adding this code: if(isset($_POST['X'])) { $_SESSION['X']=$_POST['X']; $x=$_SESSION['X']; $_SESSION['y]=$_POST['y']; $y=$_SESSION['y']; } Now, I can use $x and $y on the updated pages. Is there a better or cleaner way of doing this? Quote Link to comment Share on other sites More sharing options...
grimmier Posted April 3, 2007 Share Posted April 3, 2007 foreach($_POST as $key=>$value) { $_SESSION[$key]=$value; } that should work. might be easier for yah Quote Link to comment Share on other sites More sharing options...
RathanakBun Posted April 25, 2013 Share Posted April 25, 2013 for ($i=1;$i<10;$i++){ if (isset($_POST['btnsubmit'])){$fram=$_POST['fram_'.$i];$year=$_POST['year_'.$i];$ton=$_POST['ton_'.$i];$model=$_POST['model_'.$i];echo $fram."\t";echo $year."\t";echo $ton."\t";echo $model."\t";echo "<br>"; it echo all variable till $i<10 but if i want to echo just 5 variable it will error start from 5 to 9 how can i solve it ?? need help please!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.