I want to get html form element by post with the name being a php variable
example :
<form method="post" action="action.php"><input type="submit" name="'.$name.'"></form>
action.php code:
$var=$_POST['What do i put here?'];
Thanks
try this, use $_POST array in foreach:
action.php
foreach ($_POST as $key => $value)
echo "Field ".htmlspecialchars($key)." is ".htmlspecialchars($value)."<br>";
i hope it will be helpful.
<form method="post" action="action.php"><input type="submit" name="'.$name.'"> <input type="text" name="'.$course.'"</form> ?you can simply put it like
$_POST["{$name}"];
or
you can concatenate it like
$_POST['abc_'.$name];
To make it more clear See http://www.php.net/manual/en/language.types.string.php
Try This: print_r($_POST);
This is print all values with parameter.
echo $POST[$name];
$namevariale will come