Jump to content

[SOLVED] $_POST variables and persistence


IanG

Recommended Posts

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. 

Link to comment
https://forums.phpfreaks.com/topic/45442-solved-_post-variables-and-persistence/
Share on other sites

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?

  • 6 years later...

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!!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.