Reputation: 3184
I am building two separate forms which both include many of the same input fields. I am wondering if I should include some sort of method to unset $_POST
for these inputs after the form is submitted and relevant mailing code has run. The purpose of this would be so the user could go to the other form and fill it in also but with different data. Below is an example of a form field that will appear on both forms.
<label>What is your mortgage amount?
<input type="text" name="amount" id="[unique-id]" />
</label>
Am I better off giving each of these fields a unique name also, so as to avoid confusion? Or am I wrong in even assuming that having two fields with the same name on different forms will even affect the data posted to the second form?
Upvotes: 2
Views: 272
Reputation: 114
You should give a unique name / id for each field in your page regardless of forms . and You don't need a clear method to the $_POST. web is stateless so the data will live in the $_POST only during the same request!
Upvotes: 1
Reputation: 350
If the forms are on two different pages and the second page appears after the first one is processed it will not affect the second page.
You can refer PHP $_POST it states $_POST is "array of variables passed to the current script" only to the currently executing script.
Upvotes: 2