I am in a bit of tricky situation modifying my existing forms. Below is the flow of form. After each form submission the database insertion takes place in the subsequent form page.
<!-- this is form 1 -->
<form action="/form2.php" method="post>
<label for="policies">Policies: </label>
<select name="policies">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input type="submit" name"next" value="next">
</form>
<!-- This is form 2 -->
<form action="/form3.php" method="post>
<input type="submit" name"next" value="next">
</form>
<!-- This is form 3 -->
<form action="/form4.php" method="post>
<input type="submit" name"next" value="next">
</form>
Now I if user selects Policies as 2,3, or 4 I need to display form2 (2,3 or 4 times accordingly).
For example, if the user selects 3 policies,
I need to fill form 2,click next,fill form 2 again,click next fill,form 2 again before he goes to form 3.
This is all bit confusing. I do not know how i would go about coding such a thing.
You could use a $_SESSION[] value to track how many more times the form needs to be repeated. Session values let you persist some data over multiple scripts. Learn more about PHP sessions: http://php.net/manual/en/features.sessions.php
What you might do is record in the session how many times the policy form still needs to be filled out. If the user selects 3, you’d set $_SESSION[“policy_remaining”] = 3. Pass control over to the policy form and when it’s processed, $_SESSION[“policy_remaining”]–. if $_SESSION[“policy_remaining”] > 0, send the user back to the policy form. if $_SESSION[“policy_remaining”] == 0, send them on to form 3.