What I have typically been doing is something like this in a form with a hidden field:
<input type="hidden" name="someName" value="someVal" />
and I have been able to get the value with something simple like
$someVar = $_REQUEST['someVal'];
But now I am trying to send all the values in a DOM element id by something like this
<input type="hidden" name="someNewName" id="element_id_name" />
I am doing this correctly? Can this even be done? Or am I way off? How do I get the value out of the last line? Or how do I send that data to to request in a correct way?
Thanks, Alex
In the first case, you have to get the value of the field in php using:
For the second case, you can get value in php using:
and in javascript, you can get its value like:
You can only receive inputs with a
name
attribute, which becomes the key of your$_POST
(or equivalent) array.Please use
$_POST
(or$_GET
) instead of$_REQUEST
, the latter also looks at cookies, and one could clobber what you expect. You should follow Principle of Least Privilege.To send that one with an
id
to your server, give it a unique name or send thevalue
property to your server via XHR.you cant not retrieve data in php via ID it works on name..so you neeed to change
PHP
jQuery
on
nextpage.php
retrieve data below way
update
set
onclick=submitform()
in submit button and also assignname
andid
attribute to form and write thisjavascript
There is no such thing like DOM in HTTP protocol.
If you want to send an HTML form via HTTP request, you have to use
value
attribute, that's all