I post this here for 2 reasons: -to make sure that there is no problem with the trick, and -to share the idea, in case it is OK
I thought it as a way to post to different pages, according to different tasks available to the user. I find this trick with forms easy to implement and i made extensive use of it in a project (a beginner writing!) and it seems to work perfectly (locally testing). But i did not find it clearly suggested anywhere, so i wonder if there is any potential problem with this code. Is it "legitimate" coding really?
Part 1 (visible)
<a href="" onclick="document.form1.submit();return false;">case 1</a><br />
<a href="" onclick="document.form2.submit();return false;">case 2</a>
Part 2 (invisible, at least some form(s))
<form style="display:none;" name="form1" method="post" action="page1.php">
<input type="hidden" name="v1" id="v1" value="<?="form 1 - value 1..."?>" />
<input type="hidden" name="v2" id="v2" value="<?="form 1 - value 2..."?>" />
</form>
<form style="display:none;" name="form2" method="post" action="page1.php">
<input type="hidden" name="v1" id="v1" value="<?="form 2 - value 1..."?>" />
<input type="hidden" name="v2" id="v2" value="<?="form 2 - value 2..."?>" />
</form>
In the visible part, any elements that accept onclick can be used, for example:
<input type="Submit this" value="process 1..." onclick="document.form1.submit();" />
<input type="Submit that" value="process 2..." onclick="document.form2.submit();" />
What seems to make this invaluable is that they can lead to different pages and with different variables:
<form style="display:none;" name="form1" method="post" action="page1.php">...</form>
<form style="display:none;" name="form2" method="post" action="page2.php">...</form>
If the answer is rather negative, would it be wise to start practicing on storing values temporarily in the database? I read that, theoretically, it is the safest way, but is this true?