Is there a list of input ids or form names after the script is submitted?
Suppose I got this:
index.php generates a form with an unpredictable number of inputs with specific ids / names and different values that can be edited by the user and saved with script.php
<form action="script.php" method="post">
<input id="1" name="1" type="text" value="1"/>
<input id="24" name="24" type="text" value="2233"/>
<input id="55" name="55" type="text" value="231321"/>
</form>
Script.php:
Here I need to get something like an array of all the inputs created by index.php and store each value corresponding to its id / name.
Is there a way to do this?
+1
source to share
3 answers
Maybe your question is missing something, but the variable $_POST
will contain all the name => value pairs you are asking for. for example, in the above HTML snippet:
print_r($_POST);
// contains:
array
(
[1] => 1
[24] => 2233
[55] => 231321
)
// example access:
foreach($_POST as $name => $value) {
print "Name: {$name} Value: {$value} <br />";
}
+2
source to share