You're talking about modifying your forms on the client side, not on the server side - which means that you need to use Javascript, not PHP.
First of all, you'd need to have a <div> tag (or something similar) wrapped around the field, so you can manipulate the contents of that field with Javascript:
<div id="textfields">
<input type="text" name="field01" /><br />
</div>
The button used for adding additional fields would look something like this:
<input type="button" value="Add Field" onclick="addField();" />
And the Javascript addField() function would look something like this:
function addField() {
document.getElementById("textfields").innerHTML =
document.getElementById("textfields").innerHTML + '<input type="text" name="field02" /><br />';
}
Of course, rather than hardcoding the name of the new field as "field02", you'd want to keep track of how many fields already exist, and then increment by one. This code is just for illustrative purposes.
Finally, back on the server, your PHP code would probably look something like this:
$field_num = 1;
while ( $_POST[ "field" . str_pad( $field_num, 2, 0, STR_PAD_LEFT ) ] ) {
// ...insert code to handle each field here...
$field_num++;
}
This loop starts with $_POST["field01"], does whatever needs to be done with it, then does the same with field02, field03, etc. It terminates when the next field does not exist.
This is just a sketch - I'll leave the details up to you.