Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get a html form element with name is php variable

Tags:

html

php

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

like image 814
Jean Ouédraogo Avatar asked Oct 30 '22 23:10

Jean Ouédraogo


1 Answers

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.

like image 144
Dave Avatar answered Nov 15 '22 07:11

Dave