php - Posting variables to other pages through hidden forms? -
i post here 2 reasons: -to create sure there no problem trick, , -to share idea, in case ok
i thought way post different pages, according different tasks available user. find trick forms easy implement , made extensive utilize of in project (a beginner writing!) , seems work (locally testing). did not find suggested anywhere, wonder if there potential problem code. "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, @ to the lowest degree 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 visible part, elements take onclick can used, 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 create invaluable can lead different pages , 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 reply rather negative, wise start practicing on storing values temporarily in database? read that, theoretically, safest way, true?
php html forms variables post
No comments:
Post a Comment