PHP将变量从一个页面传输到另一个页面

I got my first PHP form working, and it submits to the database before returning to the form. But the form does not reflect the submitted values. I remember how to inject dynamic HTML based on PHP variables, but my understanding is that first there is a way to transfer php variable values from one page to another. How do you do this? Here is the end of my submission page, just in case it helps.

$STH = $DBH->prepare("UPDATE administration SET ac1= ?, ac2= ?, fan= ?, na= ?, dh= ?, tolerance1= ?, temptime1= ?, tolerance2= ?, temptime2= ?, tolerance3= ?, temptime3= ?, tolerance4= ?, temptime4= ?, tolerance5= ?, temptime5= ?, humidtolerance1= ?, humidtime1= ?, humidtolerance2= ?,  humidtime2= ?, humidtolerance3= ?,  humidtime3= ?, humidtolerance4= ?,  humidtime4= ?, humidtolerance5= ?,  humidtime5= ? WHERE custnum = ?"); 
$STH->execute(array($ac1, $ac2, $fan, $na, $dh, $tolerance1, $temptime1, $tolerance2, $temptime2, $tolerance3, $temptime3, $tolerance4, $temptime4, $tolerance5, $temptime5, $humidtolerance1, $humidtime1, $humidtolerance2, $humidtime2, $humidtolerance3, $humidtime3, $humidtolerance4, $humidtime4, $humidtolerance5, $humidtime5, $custnum));


$STH->execute();  

//Send them back to the page they were at/
header("location:index.php");

While in your case there might be better ways to achieve the overall goal, to answer your question, you can transfer variables between pages for the same user with sessions.

See the PHP manual entries:

http://il.php.net/manual/en/reserved.variables.session.php

http://il.php.net/manual/en/intro.session.php

Use super global variables to pass the data from one page to another. There are many but some of the most popular are:

  1. $_GET

    Pass the data in the form of url page.php?variable=value and read the values as `echo $_GET['variable']

  2. $_POST

    Pass the data using <form method="POST">...</form> and read the values as echo $_POST['variable']

  3. $_SESSION

    1. Start the session session_start();
    2. Declare a variable $_SESSION['variable'] = "value";
    3. Read the value echo $_SESSION['variable'];
  4. $_SERVER

    1. Declare a variable $_SERVER['variable'] = "value";
    2. Read the value echo $_SERVER['variable'];

Each of the above methods are fit in their own cases. To read more go here.