2014-07-19 45 views

回答

1

要正確地做到這一點:

  1. 瞭解PHP form handling瞭解如何獲得變量表單的(記得sanitize值!)
  2. 瞭解如何使用PHP sessions跨請求存儲變量值。

一個非常簡化的這個版本(不涉及安全或會話初始化!):

要設置值:

if (isset($_POST['field_name'])) { 
    /* cleaner_function should be changed to the proper function based on where the value is going! */ 
    $_SESSION['some_name'] = cleaner_function($_POST['field_name']); 
} 

然後,中檢索它:

if (isset($_SESSION['some_name'])) { 
    $form_value = $_SESSION['some_name']; 
}