如何保存动态表单?

I am really stuck.

All i want to do is save a form not just the data into a session, the actual form. The idea is the administrator can add as many extra's to a product. My problem is i cannot work out how to save the form into a session (current code not working). I just cannot get my head around it. I am a newbie so i am getting rather confused.

At the moment i have the dynamic form but the form and data disappear on page refresh.

enter image description here

I have created the dynamic form:

    var counter = 1;
var limit = 50; // the amount of addons that are allowed
function addInput(divName){
     if (counter == limit)  {
          alert("You have reached the limit of adding " + counter + " inputs");
     }
     else {
          var newdiv = document.createElement('div');
          newdiv.innerHTML = "Entry " + (counter + 1) + " <br><label id='cat_label' name='cat_label' class='lab'>Name</label>
\
<input type='text' id='cat_name' name='cat_name' value=''>
\
    <br>
\
    <label id='desc_label' name='desc_label' class='lab'>Description</label>
\
    <input type='text' id='cat_desc' name='cat_desc' value=''>
\
    <br>
\
    <hr id='dotted'>
\
    <br>
\
    <p id='menu_head'> Menu Item</p>
\
<input type='button' value='Add New item to ...' onClick='addInput('new item');'>";
          document.getElementById(divName).appendChild(newdiv);
          counter++;
     }
}
<div id="dynamicInput">
            <br><!--<input type="text" name="myInputs[]">-->

            <label id="cat_label"  class="lab">Name</label>
            <input type="text" id="cat_name" name="cat_name[]" value="<?php print $_SESSION['form']['cat_name'][$counter]; ?>">
            <br>
            <label id="desc_label"  class="lab">Description</label>
            <input type="text" id="cat_desc" name="cat_desc[]" value="<?php print $_SESSION['form]['cat_desc'][$counter]; ?>">

        </div>
  <input type="button" value="Add" onClick="addInput('dynamicInput');">
    <input type="submit" id="submit" name="submit" value="Save...">
</form>

I started this:

 if (count($_POST) > 2 && $_POST['submit'] == "Save...") {
$countNumberOfInputs = count($_POST['cat_name']);

foreach($_POST as $key=>$value) {

    if(!is_array($value)) {
        $value = strip_tags($value);
        $value = preg_replace("/[^0-9a-z -,.!]/i", "", $value);
    }

    $_SESSION['form'][$key] = $value;//save to session
}
if ($countNumberOfInputs < 1 ) {
$countNumberOfInputs = 1;
$counter = 0;
 }

How can i resolve this, even better could someone highlight where i went wrong?

</div>