I have a form where users enter an unbounded number of rows of data. They arrive at the form by entering whatever number of rows on the screen that they desire.
<?php
$numRows = $_GET['NUM_ROWS_REQUESTED'];
?>
<form method="post">
<?php
for($i = 0; $i < $numRows ;$i++) {
$uuid = uniqid();
?>
<input type="text" name="MYDATA[<?php print $uuid; ?>][FIRST_NAME]" />
<input type="text" name="MYDATA[<?php print $uuid; ?>][LAST_NAME]" />
<?php
}
?>
</form>
I'm wondering if, when the form is posted and I receive these records in the $_POST['MYDATA']
array if I can be guaranteed that they will be ordered in the same sequence as they were posted on the screen. Or will they be ordered by the uniqid()
that's randomly generated?
The reason I use a unique ID instead of just integers which would be easier to sequence, is that users can remove rows and add additional rows using javascript on that page. It would be too difficult to check for collisions.
MYDATA[<?php print $uuid; ?>][SORT_ORDER]
as name and a counter as value. You could also just use a counter as $uuid. If you still need a UUID you can let the server generate that or use the inverse of my first example: a hidden input withMYDATA[<?php print $counter; ?>][UUID]
as name and $uuid as value. – Lowestoft