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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.