How to _Post combination of formdata and non-formdata to php
I have a form I am creating and I would like to send information, not just from the form itself (easy enough to do with $_POST), but also generated information that corresponds to form data but is not visible to the user.
I could create a hidden input to put the data in, but I wonder if there's a way to do it that doesn't seem so hackish :)
(it's to submit a number of items, some new and some edited, I have a variable that increments for t开发者_Python百科he edited ones but not the existing ones, and I need to be able to separate them out on the other end)
You're trying to maintain state across HTTP requests...
In any case you'll have to create a temporary variable server side. Something in the $_SESSION variable. There's not safer place to put data, primarily because only the developer can access this variable.
The disadvantage of this approach is the developer will have to start maintaining sessions.
I see nothing particularly hackish in using hidden fields. If your concern is about security (you don't want that the end user is able to tamper with the data) you'll have to use some sort of persistent server-side storage such as a database or a PHP session. Whatever approach you choose, make sure your app doesn't break when the user opens several tabs.
精彩评论