sending a $id variable through hidden input tag
I have an input tag inside a form as below
- I don't know if I should place the variable $id through the value property of the input tag
i don't remember but I need that value to the URL so I can pick it up after form开发者_如何学运维 submission.
<input type="hidden" id="parent_comment" name="comments" value="'.$id.'" />
That's how you would embed a value in a form. If you want the value to be tamper-proof, then consider encrypting it somehow (http://php.net/mcrypt for one), so that it's meaningless garbage on the client, but easily transformed back to a useful value on the server.
You could store it in the session on the server, but if the user has multiple copies of the form open, the stored value would get stomped on and submitting form copy A would probably get copy B's id value.
As for retrieving the value, it'd be in $_GET['comments']
or $_POST['comments']
, depending on how you submit the form.
精彩评论