Hi everybody,
I am writing an inventory system using PHP+MySQL. The system provides simple functions like Insert, Display, Update and Delete for the user to choose in Page 1. However, for Display, Update and Delete, users then have to enter the product ID in page 2, but not for the Insert function, which should directly jump to Page 3 for inserting the item specifics.
As the different functions can go to different pages, in Page 1, I don't think I shall put all these function choices as radio buttons in the same form. One solution is to implement these 4 choices as 4 submit buttons, i.e. 4 forms are created. However, to differentiate among Display, Update and Delete, I need the HTML of Page 1 to carry some values to Page 2 depending on which submit button is being chosen, but apart from the choice of the 4 functions, users do not need to input anything else in Page 1. Hence I need a hidden input type, like this:
<form name='1' action='Page3.php' method='post'> <!-- Insert will skip Page 2 -->
<input type='Submit' value='Insert'>
</form>
<form name='2' action='Page2.php' method='post'>
<input type='hidden' name='function' value='Display'>
<input type='Submit' value='Display'>
</form>
<form name='3' action='Page2.php' method='post'>
<input type='hidden' name='function' value='Update'>
<input type='Submit' value='Update'>
</form>
<form name='4' action='Page2.php' method='post'>
<input type='hidden' name='function' value='Delete'>
<input type='Submit' value='Delete'>
</form>
So in Page 2, I can know which button is clicked from $_POST['function']. I believe this works, but is it a good practice? If not, is there any better solution?
Thanks!
--
pengi <(")