I am working on a form with fields for dimensions where a customer can fill these fields in and submit them and they will be saved in session variables. So far I succeeded 1 form, but after saving 1 time the data of the fields it needs to be possible for the costumer that he can fill in a form again (for dimensions) and still another and another etc etc.
(I started the session in top of my header)
The form:
<form method="POST">
<label>A:</label>
<input name="wz_saving_a" type="text" />
<label>B:</label>
<input name="wz_saving_b" type="text" />
<input name="wz_submit_saving_1" type="submit" class="add_button" value="Add" />
</form>
PHP for saving data in $_SESSION:
if(isset($_POST['wz_submit_saving_1'])) :
// Save submit
$_SESSION['wz_submit_saving_1'] = $_POST['wz_submit_saving_1'];
// Save wz_saving_a in session
$_SESSION['wz_saving_a'] = $_POST['wz_saving_a'];
// Save wz_saving_b in session
$_SESSION['wz_saving_b'] = $_POST['wz_saving_b'];
endif;
After submit I show the submitted data to the costumer like:
<?php if(isset($_SESSION['wz_submit_saving_1'])) : ?>
<div id="wz_config_1" class="wz_config">
<ul>
<li>Your dimensions:</li>
<li>A: <?php if(isset($_SESSION['wz_saving_a'])) : echo $_SESSION['wz_saving_a']; endif; ?> mm</li>
<li>B: <?php if(isset($_SESSION['wz_saving_b'])) : echo $_SESSION['wz_saving_b']; endif; ?> mm</li>
</ul>
<?php endif; ?>
So this works for 1 submit and if I submit the form the session variables of the first will be refreshed by the new data, but now I need something to do so the costumer can add multiple dimensions sets and save in the Session.
My idea was to change every name of a field by _1 _2 _3 after each form submit. But I don't know how to fix this so I hope someone can give me some advice.
I can give the url of my example if you want?
Thanks!