I have this HTML form:
<form action="" method="post">
<input type="hidden" name="data_first" value="9" />
<input type="hidden" name="data_second" value="2" />
<input type="hidden" name="date" value="2018-01-25" />
<input type="text" name="posted_data" value="0.1" />
</form>
I want combine this Posted data, with serialize function
.
I can serialize only one input. example: serialize($_POST['posted_data']);
I need function like this:
serialize($_POST['posted_data'],$_POST['data_first'],$_POST['data_second'],$_POST['date']);
Any ideas?
You can simply do -
serialize($_POST);
It will serialize all the posted data. And then process them accordingly.
Update
You can use input arrays -
<form action="" method="post">
<input type="hidden" name="data[data_first]" value="9" />
<input type="hidden" name="data[data_second]" value="2" />
<input type="hidden" name="data[date]" value="2018-01-25" />
<input type="text" name="data[posted_data]" value="0.1" />
</form>
And
serialize($_POST['data']);
Will serialize those specific inputs present in data
.
there are two ways
1) By sending post array
e.g serialize($_POST)
2) By sending post data through array e.g serialize(array($_POST['posted_data'],$_POST['data_first'],$_POST['data_second'],$_POST['date']));